Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
91007ba
Revert "[RESTRICT AUTOMERGE] Trim the activity info of another uid if…
Jan 4, 2023
3ef763a
Move service initialization
May 16, 2022
5040a36
Enable user graularity for lockdown mode
wenhao1006 Aug 30, 2022
c0bf2f8
Reconcile WorkSource parcel and unparcel code.
Sep 26, 2022
ec76629
Enforce MediaButtonReceiver extracted component name matches session …
ivanbuper Oct 4, 2022
bd980c2
Enforce MediaButtonReceiver ComponentName belongs to app
ivanbuper Sep 6, 2022
9eb8348
Revert "Ensure that only SysUI can override pending intent launch flags"
Jan 11, 2023
0999c8e
DO NOT MERGE: Context#startInstrumentation could be started from SHEL…
Aug 4, 2022
198a39f
Fix checkKeyIntentParceledCorrectly's bypass
haok-ggl Dec 12, 2022
7844f52
Checking if package belongs to UID before registering broadcast receiver
Nov 7, 2022
8ee7c4a
Encode Intent scheme when serializing to URI string RESTRICT AUTOMERGE
Jan 6, 2023
64537dd
[RESTRICT AUTOMERGE] Strip part of the activity info of another uid i…
Sep 28, 2022
0a4ce9d
Add a limit on channel group creation
Jan 18, 2022
642c978
Fix bypass BAL via LocationManager.requestFlush
Jan 26, 2023
1c619ed
[RESTRICT AUTOMERGE] Fix bypass BG-FGS and BAL via package manager APIs
Jan 11, 2023
281c6c3
Revert "Make Activites touch opaque - DO NOT MERGE"
jwdunlap Mar 1, 2023
f1087da
[RESTRICT AUTOMERGE][pm] prevent system app downgrades of versions lo…
schfan-1 Jan 27, 2023
ebc0bad
[RESTRICT AUTOMERGE][pm] still allow debuggable for system app downgr…
schfan-1 Feb 2, 2023
1b168c5
Checks if AccessibilityServiceInfo is within parcelable size.
Daniel-Norman Feb 9, 2023
0ea18d4
Uri: check authority and scheme as part of determining URI path
ohodson Apr 7, 2022
e058a1b
enforce stricter rules when registering phoneAccounts
ThomasStuart Nov 22, 2022
767f4e6
Make Activites touch opaque - DO NOT MERGE
Mar 1, 2023
4f9f35f
Trim strings added to persistent snoozed notification storage.
Jan 5, 2023
252c585
Limit the number of shortcuts per app that can be retained by system
pinyaoting Feb 15, 2023
4a7948f
Re-enforce MANAGE_ACTIVITY_TASKS for applySyncTransaction
Feb 13, 2023
5b10fc9
Remove Activity if it enters PiP without window
hwwang-google Feb 23, 2023
e6a5e67
[DO NOT MERGE] Wait for preloading images to complete before inflatin…
Feb 15, 2023
1e5ccd6
[DO NOT MERGE] Prevent RemoteViews crashing SystemUi
Feb 22, 2023
b775a43
Grant MANAGE_USERS access to Traceur
kevinjeon-g Mar 17, 2023
bd69b95
Check key intent for selectors and prohibited flags
g-brnlee Feb 18, 2023
e9b549b
Handle invalid data during job loading.
kwadkore Sep 21, 2022
2a7b6bf
Allow filtering of services
Mar 7, 2023
1058046
Enforce DevicePolicyManager.setUserControlDisabledPackages in AppStan…
acjohnstong Mar 8, 2023
00d135a
[RESTRICT AUTOMERGE] Add BubbleMetadata detection to block FSI
Mar 24, 2023
06b718e
Prevent sharesheet from previewing unowned URIs
Feb 22, 2023
1d6e562
Sanitize VPN label to prevent HTML injection
Mar 3, 2023
9f10396
Limit the number of supported v1 and v2 signers
mpgroover Mar 31, 2023
4fc2559
Grant URI permissions to the CallStyle-related ones
Apr 13, 2023
bc911be
Only allow NEW_TASK flag when adjusting pending intents
Feb 8, 2023
370f495
Dismiss keyguard when simpin auth'd and...
Mar 28, 2023
26cde56
Verify URI permissions for EXTRA_REMOTE_INPUT_HISTORY_ITEMS.
Apr 21, 2023
33e0680
Truncate ShortcutInfo Id
Apr 21, 2023
0a45958
Visit URIs in landscape/portrait custom remote views.
Apr 27, 2023
39851ee
[DO NOT MERGE] Backport BAL restrictions from T to S, this blocks app…
Dec 28, 2022
eddde88
DO NOT MERGE: ActivityManager#killBackgroundProcesses can kill caller…
Oct 26, 2022
57d066c
ActivityManagerService: Allow openContentUri from vendor/system/product.
gborgera2 Mar 18, 2023
94664d1
Do not load drawable for wallet card if the card image icon iscreated
Apr 12, 2023
d934296
Verify URI permissions for notification shortcutIcon.
Apr 27, 2023
2b2b778
Ensure policy has no absurdly long strings
Apr 5, 2023
1bae3b1
On device lockdown, always show the keyguard
May 8, 2023
45e38e6
Preserve flags for non-runtime permissions upon package update.
zhanghai May 17, 2023
5a1f603
Check URIs in notification public version.
May 15, 2023
29a2885
Implement visitUris for RemoteViews ViewGroupActionAdd.
May 12, 2023
f0d3655
Validate ComponentName for MediaButtonBroadcastReceiver
ivanbuper Apr 4, 2023
0b922fe
Check URIs in sized remote views.
May 23, 2023
6de8b77
Fix PrivacyChip not visible issue
May 22, 2023
8ab4f75
Visit URIs in themed remoteviews icons.
May 25, 2023
d82bcdf
Merge "Use Settings.System.getIntForUser instead of getInt to make su…
Jun 2, 2023
9765e7a
Remove unnecessary padding code
May 19, 2023
3a54ae3
Verify URI permissions in MediaMetadata
Apr 28, 2023
3fa0e42
Merge "Resolve StatusHints image exploit across user." into rvc-dev a…
Jun 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void restrictApp(@NonNull String packageName, int userId, int mainReason,

void setActiveAdminApps(Set<String> adminPkgs, int userId);

void setAdminProtectedPackages(Set<String> packageNames, int userId);

void onAdminDataAvailable();

void clearCarrierPrivilegedApps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.ActivityManagerInternal;
import android.app.ActivityOptions;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
Expand Down Expand Up @@ -323,6 +324,8 @@ interface Stats {
private final SparseBooleanArray mPendingSendNextAlarmClockChangedForUser =
new SparseBooleanArray();
private boolean mNextAlarmClockMayChange;
ActivityOptions mActivityOptsRestrictBal = ActivityOptions.makeBasic();
BroadcastOptions mBroadcastOptsRestrictBal = BroadcastOptions.makeBasic();

@GuardedBy("mLock")
private final Runnable mAlarmClockUpdater = () -> mNextAlarmClockMayChange = true;
Expand Down Expand Up @@ -1651,6 +1654,11 @@ public void dumpDebug(ProtoOutputStream proto, long fieldId) {
@Override
public void onStart() {
mInjector.init();
mOptsWithFgs.setPendingIntentBackgroundActivityLaunchAllowed(false);
mOptsWithoutFgs.setPendingIntentBackgroundActivityLaunchAllowed(false);
mOptsTimeBroadcast.setPendingIntentBackgroundActivityLaunchAllowed(false);
mActivityOptsRestrictBal.setPendingIntentBackgroundActivityLaunchAllowed(false);
mBroadcastOptsRestrictBal.setPendingIntentBackgroundActivityLaunchAllowed(false);
mMetricsHelper = new MetricsHelper(getContext(), mLock);

mListenerDeathRecipient = new IBinder.DeathRecipient() {
Expand Down Expand Up @@ -4404,6 +4412,14 @@ private static int getAlarmAttributionUid(Alarm alarm) {
return alarm.creatorUid;
}

private Bundle getAlarmOperationBundle(Alarm alarm) {
if (alarm.mIdleOptions != null) {
return alarm.mIdleOptions;
} else if (alarm.operation.isActivity()) {
return mActivityOptsRestrictBal.toBundle();
}
return mBroadcastOptsRestrictBal.toBundle();
}

@VisibleForTesting
class AlarmHandler extends Handler {
Expand Down Expand Up @@ -4452,13 +4468,24 @@ public void handleMessage(Message msg) {
}
}
} else {
removeImpl(alarm.operation, null);
try {
// Disallow AlarmManager to start random background activity.
final Bundle bundle = getAlarmOperationBundle(alarm);
alarm.operation.send(/* context */ null, /* code */ 0, /* intent */
null, /* onFinished */ null, /* handler */
null, /* requiredPermission */ null, bundle);
} catch (PendingIntent.CanceledException e) {
if (alarm.repeatInterval > 0) {
// This IntentSender is no longer valid, but this
// is a repeating alarm, so toss the hoser.
removeImpl(alarm.operation, null);
}
}
}
decrementAlarmCount(alarm.uid, 1);
}
break;
}

case SEND_NEXT_ALARM_CLOCK_CHANGED:
sendNextAlarmClockChanged();
break;
Expand Down Expand Up @@ -5010,9 +5037,10 @@ public void deliverLocked(Alarm alarm, long nowELAPSED) {
mSendCount++;

try {
final Bundle bundle = getAlarmOperationBundle(alarm);
alarm.operation.send(getContext(), 0,
mBackgroundIntent.putExtra(Intent.EXTRA_ALARM_COUNT, alarm.count),
mDeliveryTracker, mHandler, null, alarm.mIdleOptions);
mDeliveryTracker, mHandler, null, bundle);
} catch (PendingIntent.CanceledException e) {
if (alarm.repeatInterval > 0) {
// This IntentSender is no longer valid, but this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,10 @@ public void run() {
}
} catch (XmlPullParserException | IOException e) {
Slog.wtf(TAG, "Error jobstore xml.", e);
} catch (Exception e) {
// Crashing at this point would result in a boot loop, so live with a general
// Exception for system stability's sake.
Slog.wtf(TAG, "Unexpected exception", e);
} finally {
if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once.
mPersistInfo.countAllJobsLoaded = numJobs;
Expand Down Expand Up @@ -869,6 +873,9 @@ private JobStatus restoreJobFromXml(boolean rtcIsGood, XmlPullParser parser)
} catch (IOException e) {
Slog.d(TAG, "Error I/O Exception.", e);
return null;
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Constraints contained invalid data", e);
return null;
}

parser.next(); // Consume </constraints>
Expand Down Expand Up @@ -965,8 +972,14 @@ private JobStatus restoreJobFromXml(boolean rtcIsGood, XmlPullParser parser)
return null;
}

PersistableBundle extras = PersistableBundle.restoreFromXml(parser);
jobBuilder.setExtras(extras);
final PersistableBundle extras;
try {
extras = PersistableBundle.restoreFromXml(parser);
jobBuilder.setExtras(extras);
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Persisted extras contained invalid data", e);
return null;
}
parser.nextTag(); // Consume </extras>

final JobInfo builtJob;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ static class Lock {}
@GuardedBy("mActiveAdminApps")
private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>();

/** List of admin protected packages. Can contain {@link android.os.UserHandle#USER_ALL}. */
@GuardedBy("mAdminProtectedPackages")
private final SparseArray<Set<String>> mAdminProtectedPackages = new SparseArray<>();

/**
* Set of system apps that are headless (don't have any declared activities, enabled or
* disabled). Presence in this map indicates that the app is a headless system app.
Expand Down Expand Up @@ -1088,6 +1092,9 @@ public void onUserRemoved(int userId) {
synchronized (mActiveAdminApps) {
mActiveAdminApps.remove(userId);
}
synchronized (mAdminProtectedPackages) {
mAdminProtectedPackages.remove(userId);
}
}
}

Expand Down Expand Up @@ -1177,6 +1184,10 @@ private int getAppMinBucket(String packageName, int appId, int userId) {
return STANDBY_BUCKET_EXEMPTED;
}

if (isAdminProtectedPackages(packageName, userId)) {
return STANDBY_BUCKET_EXEMPTED;
}

if (isActiveNetworkScorer(packageName)) {
return STANDBY_BUCKET_EXEMPTED;
}
Expand Down Expand Up @@ -1583,6 +1594,17 @@ boolean isActiveDeviceAdmin(String packageName, int userId) {
}
}

private boolean isAdminProtectedPackages(String packageName, int userId) {
synchronized (mAdminProtectedPackages) {
if (mAdminProtectedPackages.contains(UserHandle.USER_ALL)
&& mAdminProtectedPackages.get(UserHandle.USER_ALL).contains(packageName)) {
return true;
}
return mAdminProtectedPackages.contains(userId)
&& mAdminProtectedPackages.get(userId).contains(packageName);
}
}

@Override
public void addActiveDeviceAdmin(String adminPkg, int userId) {
synchronized (mActiveAdminApps) {
Expand All @@ -1606,6 +1628,17 @@ public void setActiveAdminApps(Set<String> adminPkgs, int userId) {
}
}

@Override
public void setAdminProtectedPackages(Set<String> packageNames, int userId) {
synchronized (mAdminProtectedPackages) {
if (packageNames == null || packageNames.isEmpty()) {
mAdminProtectedPackages.remove(userId);
} else {
mAdminProtectedPackages.put(userId, packageNames);
}
}
}

@Override
public void onAdminDataAvailable() {
mAdminDataAvailableLatch.countDown();
Expand All @@ -1628,6 +1661,13 @@ Set<String> getActiveAdminAppsForTest(int userId) {
}
}

@VisibleForTesting
Set<String> getAdminProtectedPackagesForTest(int userId) {
synchronized (mAdminProtectedPackages) {
return mAdminProtectedPackages.get(userId);
}
}

/**
* Returns {@code true} if the supplied package is the device provisioning app. Otherwise,
* returns {@code false}.
Expand Down
2 changes: 1 addition & 1 deletion core/api/test-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,7 @@ package android.window {

public class WindowOrganizer {
ctor public WindowOrganizer();
method @RequiresPermission(value=android.Manifest.permission.MANAGE_ACTIVITY_TASKS, conditional=true) public int applySyncTransaction(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.WindowContainerTransactionCallback);
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public int applySyncTransaction(@NonNull android.window.WindowContainerTransaction, @NonNull android.window.WindowContainerTransactionCallback);
method @RequiresPermission(value=android.Manifest.permission.MANAGE_ACTIVITY_TASKS, conditional=true) public void applyTransaction(@NonNull android.window.WindowContainerTransaction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,10 @@ private void sendServiceInfo() {
IAccessibilityServiceConnection connection =
AccessibilityInteractionClient.getInstance(this).getConnection(mConnectionId);
if (mInfo != null && connection != null) {
if (!mInfo.isWithinParcelableSize()) {
throw new IllegalStateException(
"Cannot update service info: size is larger than safe parcelable limits.");
}
try {
connection.setServiceInfo(mInfo);
mInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
Expand Down Expand Up @@ -1063,6 +1064,15 @@ public int describeContents() {
return 0;
}

/** @hide */
public final boolean isWithinParcelableSize() {
final Parcel parcel = Parcel.obtain();
writeToParcel(parcel, 0);
final boolean result = parcel.dataSize() <= IBinder.MAX_IPC_SIZE;
parcel.recycle();
return result;
}

public void writeToParcel(Parcel parcel, int flagz) {
parcel.writeInt(eventTypes);
parcel.writeStringArray(packageNames);
Expand Down
3 changes: 3 additions & 0 deletions core/java/android/app/ActivityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3666,6 +3666,9 @@ public void restartPackage(String packageName) {
* processes to reclaim memory; the system will take care of restarting
* these processes in the future as needed.
*
* <p class="note">Third party applications can only use this API to kill their own processes.
* </p>
*
* @param packageName The name of the package whose processes are to
* be killed.
*/
Expand Down
16 changes: 10 additions & 6 deletions core/java/android/app/ActivityOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_RECEIVER_FOREGROUND;
import static android.view.Display.INVALID_DISPLAY;

import android.annotation.IntDef;
Expand Down Expand Up @@ -69,7 +71,7 @@
* {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle)
* Context.startActivity(Intent, Bundle)} and related methods.
*/
public class ActivityOptions {
public class ActivityOptions extends ComponentOptions {
private static final String TAG = "ActivityOptions";

/**
Expand Down Expand Up @@ -1081,13 +1083,12 @@ public boolean getLaunchTaskBehind() {
}

private ActivityOptions() {
super();
}

/** @hide */
public ActivityOptions(Bundle opts) {
// If the remote side sent us bad parcelables, they won't get the
// results they want, which is their loss.
opts.setDefusable(true);
super(opts);

mPackageName = opts.getString(KEY_PACKAGE_NAME);
try {
Expand Down Expand Up @@ -1554,7 +1555,9 @@ public void setPendingIntentLaunchFlags(@android.content.Intent.Flags int flags)
* @hide
*/
public int getPendingIntentLaunchFlags() {
return mPendingIntentLaunchFlags;
// b/243794108: Ignore all flags except the new task flag, to be reconsidered in b/254490217
return mPendingIntentLaunchFlags &
(FLAG_ACTIVITY_NEW_TASK | FLAG_RECEIVER_FOREGROUND);
}

/**
Expand Down Expand Up @@ -1832,8 +1835,9 @@ public void update(ActivityOptions otherOptions) {
* object; you must not modify it, but can supply it to the startActivity
* methods that take an options Bundle.
*/
@Override
public Bundle toBundle() {
Bundle b = new Bundle();
Bundle b = super.toBundle();
if (mPackageName != null) {
b.putString(KEY_PACKAGE_NAME, mPackageName);
}
Expand Down
25 changes: 23 additions & 2 deletions core/java/android/app/BroadcastOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* {@hide}
*/
@SystemApi
public class BroadcastOptions {
public class BroadcastOptions extends ComponentOptions {
private long mTemporaryAppAllowlistDuration;
private @TempAllowListType int mTemporaryAppAllowlistType;
private @ReasonCode int mTemporaryAppAllowlistReasonCode;
Expand Down Expand Up @@ -108,12 +108,14 @@ public static BroadcastOptions makeBasic() {
}

private BroadcastOptions() {
super();
resetTemporaryAppAllowlist();
}

/** @hide */
@TestApi
public BroadcastOptions(@NonNull Bundle opts) {
super(opts);
// Match the logic in toBundle().
if (opts.containsKey(KEY_TEMPORARY_APP_ALLOWLIST_DURATION)) {
mTemporaryAppAllowlistDuration = opts.getLong(KEY_TEMPORARY_APP_ALLOWLIST_DURATION);
Expand Down Expand Up @@ -190,6 +192,24 @@ private void resetTemporaryAppAllowlist() {
mTemporaryAppAllowlistReason = null;
}

/**
* Set PendingIntent activity is allowed to be started in the background if the caller
* can start background activities.
* @hide
*/
public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) {
super.setPendingIntentBackgroundActivityLaunchAllowed(allowed);
}

/**
* Get PendingIntent activity is allowed to be started in the background if the caller
* can start background activities.
* @hide
*/
public boolean isPendingIntentBackgroundActivityLaunchAllowed() {
return super.isPendingIntentBackgroundActivityLaunchAllowed();
}

/**
* Return {@link #setTemporaryAppAllowlist}.
* @hide
Expand Down Expand Up @@ -308,8 +328,9 @@ public boolean allowsBackgroundActivityStarts() {
* object; you must not modify it, but can supply it to the sendBroadcast
* methods that take an options Bundle.
*/
@Override
public Bundle toBundle() {
Bundle b = new Bundle();
Bundle b = super.toBundle();
if (isTemporaryAppAllowlistSet()) {
b.putLong(KEY_TEMPORARY_APP_ALLOWLIST_DURATION, mTemporaryAppAllowlistDuration);
b.putInt(KEY_TEMPORARY_APP_ALLOWLIST_TYPE, mTemporaryAppAllowlistType);
Expand Down
Loading