diff options
| author | 2024-03-09 10:43:20 +0000 | |
|---|---|---|
| committer | 2024-03-09 10:43:20 +0000 | |
| commit | b4d8075246e08bc595bbba512a4c545eaa098434 (patch) | |
| tree | 7311a676a75597e36295e7430c735e0654a5defa | |
| parent | 24be2e1f225990c4174aea1b4c884c604570c19b (diff) | |
| parent | 2cd75ddf00495ea32f97b96289f56d56e36a4c29 (diff) | |
Merge "Remove modern_queue_enabled flag." into main
9 files changed, 27 insertions, 136 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 39823a863b4a..fae434828222 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -6054,20 +6054,6 @@ public class ActivityManager { } /** - * Checks if the "modern" broadcast queue is enabled. - * - * @hide - */ - @RequiresPermission(android.Manifest.permission.DUMP) - public boolean isModernBroadcastQueueEnabled() { - try { - return getService().isModernBroadcastQueueEnabled(); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - - /** * Checks if the process represented by the given {@code pid} is frozen. * * @hide diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index 062b89ed57ba..e28a6ce9b423 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -226,12 +226,6 @@ public abstract class ActivityManagerInternal { public abstract boolean isSystemReady(); /** - * @return {@code true} if system is using the "modern" broadcast queue, - * {@code false} otherwise. - */ - public abstract boolean isModernQueueEnabled(); - - /** * Enforce capability restrictions on use of the given BroadcastOptions */ public abstract void enforceBroadcastOptionsPermissions(@Nullable Bundle options, diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index 7a95720c1cf4..5e6b54b1d0ea 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -898,10 +898,6 @@ interface IActivityManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)") void forceDelayBroadcastDelivery(in String targetPackage, long delayedDurationMs); - /** Checks if the modern broadcast queue is enabled. */ - @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)") - boolean isModernBroadcastQueueEnabled(); - /** Checks if the process represented by the given pid is frozen. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)") boolean isProcessFrozen(int pid); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 7bd67453624f..60bfc637225f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -725,12 +725,6 @@ public class ActivityManagerService extends IActivityManager.Stub // Whether we should use SCHED_FIFO for UI and RenderThreads. final boolean mUseFifoUiScheduling; - /** - * Flag indicating if we should use {@link BroadcastQueueModernImpl} instead - * of the default {@link BroadcastQueueImpl}. - */ - final boolean mEnableModernQueue; - @GuardedBy("this") private final SparseArray<IUnsafeIntentStrictModeCallback> mStrictModeCallbacks = new SparseArray<>(); @@ -2508,7 +2502,6 @@ public class ActivityManagerService extends IActivityManager.Stub mInternal = new LocalService(); mPendingStartActivityUids = new PendingStartActivityUids(); mUseFifoUiScheduling = false; - mEnableModernQueue = false; mBroadcastQueue = injector.getBroadcastQueue(this); mComponentAliasResolver = new ComponentAliasResolver(this); } @@ -2550,9 +2543,6 @@ public class ActivityManagerService extends IActivityManager.Stub ? new OomAdjusterModernImpl(this, mProcessList, activeUids) : new OomAdjuster(this, mProcessList, activeUids); - mEnableModernQueue = new BroadcastConstants( - Settings.Global.BROADCAST_FG_CONSTANTS).MODERN_QUEUE_ENABLED; - mBroadcastQueue = mInjector.getBroadcastQueue(this); mServices = new ActiveServices(this); @@ -15025,9 +15015,6 @@ public class ActivityManagerService extends IActivityManager.Stub + " ordered=" + ordered + " userid=" + userId + " options=" + (brOptions == null ? "null" : brOptions.toBundle())); if ((resultTo != null) && !ordered) { - if (!mEnableModernQueue) { - Slog.w(TAG, "Broadcast " + intent + " not ordered but result callback requested!"); - } if (!UserHandle.isCore(callingUid)) { String msg = "Unauthorized unordered resultTo broadcast " + intent + " sent from uid " + callingUid; @@ -15628,29 +15615,6 @@ public class ActivityManagerService extends IActivityManager.Stub filterNonExportedComponents(intent, callingUid, callingPid, registeredReceivers, mPlatformCompat, callerPackage, resolvedType); int NR = registeredReceivers != null ? registeredReceivers.size() : 0; - if (!ordered && NR > 0 && !mEnableModernQueue) { - // If we are not serializing this broadcast, then send the - // registered receivers separately so they don't wait for the - // components to be launched. We don't do this split for the modern - // queue because delivery to registered receivers isn't blocked - // behind manifest receivers. - if (isCallerSystem) { - checkBroadcastFromSystem(intent, callerApp, callerPackage, callingUid, - isProtectedBroadcast, registeredReceivers); - } - final BroadcastQueue queue = mBroadcastQueue; - BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp, callerPackage, - callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, - requiredPermissions, excludedPermissions, excludedPackages, appOp, brOptions, - registeredReceivers, resultToApp, resultTo, resultCode, resultData, - resultExtras, ordered, sticky, false, userId, - backgroundStartPrivileges, timeoutExempt, filterExtrasForReceiver, - callerAppProcessState); - if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r); - queue.enqueueBroadcastLocked(r); - registeredReceivers = null; - NR = 0; - } // Merge into one list. int ir = 0; @@ -18302,11 +18266,6 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override - public boolean isModernQueueEnabled() { - return mEnableModernQueue; - } - - @Override public void enforceBroadcastOptionsPermissions(Bundle options, int callingUid) { enforceBroadcastOptionPermissionsInternal(options, callingUid); } @@ -18735,7 +18694,6 @@ public class ActivityManagerService extends IActivityManager.Stub Binder.restoreCallingIdentity(origId); } } - } @Override @@ -18745,12 +18703,8 @@ public class ActivityManagerService extends IActivityManager.Stub int userId, int[] appIdAllowList, @Nullable BiFunction<Integer, Bundle, Bundle> filterExtrasForReceiver, @Nullable Bundle bOptions) { - // Sending broadcasts with a finish callback without the need for the broadcasts - // delivery to be serialized is only supported by modern queue. So, when modern - // queue is disabled, we continue to send broadcasts in a serialized fashion. - final boolean serialized = !isModernQueueEnabled(); - return broadcastIntent(intent, resultTo, requiredPermissions, serialized, userId, - appIdAllowList, filterExtrasForReceiver, bOptions); + return broadcastIntent(intent, resultTo, requiredPermissions, false /* serialized */, + userId, appIdAllowList, filterExtrasForReceiver, bOptions); } @Override @@ -19789,21 +19743,11 @@ public class ActivityManagerService extends IActivityManager.Stub Objects.requireNonNull(targetPackage); Preconditions.checkArgumentNonnegative(delayedDurationMs); enforceCallingPermission(permission.DUMP, "forceDelayBroadcastDelivery()"); - // Ignore request if modern queue is not enabled - if (!mEnableModernQueue) { - return; - } mBroadcastQueue.forceDelayBroadcastDelivery(targetPackage, delayedDurationMs); } @Override - public boolean isModernBroadcastQueueEnabled() { - enforceCallingPermission(permission.DUMP, "isModernBroadcastQueueEnabled()"); - return mEnableModernQueue; - } - - @Override public boolean isProcessFrozen(int pid) { enforceCallingPermission(permission.DUMP, "isProcessFrozen()"); return mOomAdjuster.mCachedAppOptimizer.isProcessFrozen(pid); diff --git a/services/core/java/com/android/server/am/BroadcastConstants.java b/services/core/java/com/android/server/am/BroadcastConstants.java index 887915d78bc9..57080f8b2d42 100644 --- a/services/core/java/com/android/server/am/BroadcastConstants.java +++ b/services/core/java/com/android/server/am/BroadcastConstants.java @@ -128,14 +128,6 @@ public class BroadcastConstants { public long ALLOW_BG_ACTIVITY_START_TIMEOUT = DEFAULT_ALLOW_BG_ACTIVITY_START_TIMEOUT; /** - * Flag indicating if we should use {@link BroadcastQueueModernImpl} instead - * of the default {@link BroadcastQueueImpl}. - */ - public boolean MODERN_QUEUE_ENABLED = DEFAULT_MODERN_QUEUE_ENABLED; - private static final String KEY_MODERN_QUEUE_ENABLED = "modern_queue_enabled"; - private static final boolean DEFAULT_MODERN_QUEUE_ENABLED = true; - - /** * For {@link BroadcastQueueModernImpl}: Maximum dispatch parallelism * that we'll tolerate for ordinary broadcast dispatch. */ @@ -421,8 +413,6 @@ public class BroadcastConstants { */ private void updateDeviceConfigConstants() { synchronized (this) { - MODERN_QUEUE_ENABLED = getDeviceConfigBoolean(KEY_MODERN_QUEUE_ENABLED, - DEFAULT_MODERN_QUEUE_ENABLED); MAX_RUNNING_PROCESS_QUEUES = getDeviceConfigInt(KEY_MAX_RUNNING_PROCESS_QUEUES, DEFAULT_MAX_RUNNING_PROCESS_QUEUES); EXTRA_RUNNING_URGENT_PROCESS_QUEUES = getDeviceConfigInt( @@ -498,7 +488,6 @@ public class BroadcastConstants { pw.print(NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT); pw.println("):"); pw.increaseIndent(); - pw.print(KEY_MODERN_QUEUE_ENABLED, MODERN_QUEUE_ENABLED).println(); pw.print(KEY_MAX_RUNNING_PROCESS_QUEUES, MAX_RUNNING_PROCESS_QUEUES).println(); pw.print(KEY_MAX_RUNNING_ACTIVE_BROADCASTS, MAX_RUNNING_ACTIVE_BROADCASTS).println(); pw.print(KEY_CORE_MAX_RUNNING_BLOCKING_BROADCASTS, diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index 13a1807b3563..70d447fce18a 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -646,7 +646,7 @@ class UserController implements Handler.Callback { new String[]{android.Manifest.permission.RECEIVE_BOOT_COMPLETED}, AppOpsManager.OP_NONE, getTemporaryAppAllowlistBroadcastOptions(REASON_LOCKED_BOOT_COMPLETED) - .toBundle(), true, + .toBundle(), false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), userId); } @@ -740,7 +740,7 @@ class UserController implements Handler.Callback { unlockedIntent.addFlags( Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); mInjector.broadcastIntent(unlockedIntent, null, null, 0, null, - null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, + null, null, AppOpsManager.OP_NONE, null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), userId); } @@ -765,7 +765,7 @@ class UserController implements Handler.Callback { | Intent.FLAG_RECEIVER_FOREGROUND); mInjector.broadcastIntent(profileUnlockedIntent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, - null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), + null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), parent.id); } } @@ -824,7 +824,7 @@ class UserController implements Handler.Callback { initializeUser.run(); } }, 0, null, null, null, AppOpsManager.OP_NONE, - null, true, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), + null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), userId); } } @@ -876,7 +876,7 @@ class UserController implements Handler.Callback { new String[]{android.Manifest.permission.RECEIVE_BOOT_COMPLETED}, AppOpsManager.OP_NONE, getTemporaryAppAllowlistBroadcastOptions(REASON_BOOT_COMPLETED).toBundle(), - true, false, MY_PID, SYSTEM_UID, callingUid, callingPid, userId); + false, MY_PID, SYSTEM_UID, callingUid, callingPid, userId); }); } @@ -1124,7 +1124,7 @@ class UserController implements Handler.Callback { mInjector.broadcastIntent(stoppingIntent, null, stoppingReceiver, 0, null, null, new String[]{INTERACT_ACROSS_USERS}, AppOpsManager.OP_NONE, - null, true, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), + null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL); }); } @@ -1187,7 +1187,7 @@ class UserController implements Handler.Callback { mInjector.broadcastIntent(shutdownIntent, null, shutdownReceiver, 0, null, null, null, AppOpsManager.OP_NONE, - null, true, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), + null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), userId); } @@ -1464,7 +1464,7 @@ class UserController implements Handler.Callback { intent.putExtra(Intent.EXTRA_USER_HANDLE, userId); mInjector.broadcastIntent(intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, - null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), + null, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL); // Send PROFILE_INACCESSIBLE broadcast if a profile was stopped @@ -2404,7 +2404,7 @@ class UserController implements Handler.Callback { mInjector.broadcastIntent(intent, /* resolvedType= */ null, /* resultTo= */ null, /* resultCode= */ 0, /* resultData= */ null, /* resultExtras= */ null, /* requiredPermissions= */ null, AppOpsManager.OP_NONE, /* bOptions= */ null, - /* ordered= */ false, /* sticky= */ false, MY_PID, SYSTEM_UID, + /* sticky= */ false, MY_PID, SYSTEM_UID, callingUid, callingPid, userId); } @@ -2432,7 +2432,7 @@ class UserController implements Handler.Callback { } }, /* resultCode= */ 0, /* resultData= */ null, /* resultExtras= */ null, new String[]{INTERACT_ACROSS_USERS}, AppOpsManager.OP_NONE, /* bOptions= */ null, - /* ordered= */ true, /* sticky= */ false, MY_PID, SYSTEM_UID, + /* sticky= */ false, MY_PID, SYSTEM_UID, callingUid, callingPid, UserHandle.USER_ALL); } @@ -2457,7 +2457,7 @@ class UserController implements Handler.Callback { intent.putExtra(Intent.EXTRA_USER, UserHandle.of(profileUserId)); mInjector.broadcastIntent(intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, - null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid, + null, false, MY_PID, SYSTEM_UID, callingUid, callingPid, profileUserId); } } @@ -2476,7 +2476,7 @@ class UserController implements Handler.Callback { intent.putExtra(Intent.EXTRA_USER, UserHandle.of(profileUserId)); mInjector.broadcastIntent(intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, - null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid, + null, false, MY_PID, SYSTEM_UID, callingUid, callingPid, profileUserId); } intent = new Intent(Intent.ACTION_USER_SWITCHED); @@ -2489,7 +2489,7 @@ class UserController implements Handler.Callback { mInjector.broadcastIntent(intent, null, null, 0, null, null, new String[] {android.Manifest.permission.MANAGE_USERS}, - AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, callingUid, + AppOpsManager.OP_NONE, null, false, MY_PID, SYSTEM_UID, callingUid, callingPid, UserHandle.USER_ALL); } } finally { @@ -2513,7 +2513,7 @@ class UserController implements Handler.Callback { mInjector.broadcastIntent(intent, /* resolvedType= */ null, /* resultTo= */ null, /* resultCode= */ 0, /* resultData= */ null, /* resultExtras= */ null, /* requiredPermissions= */ null, AppOpsManager.OP_NONE, /* bOptions= */ - null, /* ordered= */ false, /* sticky= */ false, MY_PID, SYSTEM_UID, + null, /* sticky= */ false, MY_PID, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), parentId); } @@ -3576,7 +3576,7 @@ class UserController implements Handler.Callback { protected int broadcastIntent(Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions, - boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid, + boolean sticky, int callingPid, int callingUid, int realCallingUid, int realCallingPid, @UserIdInt int userId) { int logUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); @@ -3585,21 +3585,13 @@ class UserController implements Handler.Callback { } EventLog.writeEvent(EventLogTags.UC_SEND_USER_BROADCAST, logUserId, intent.getAction()); - // When the modern broadcast stack is enabled, deliver all our - // broadcasts as unordered, since the modern stack has better - // support for sequencing cold-starts, and it supports delivering - // resultTo for non-ordered broadcasts - if (mService.mEnableModernQueue) { - ordered = false; - } - TimingsTraceAndSlog t = new TimingsTraceAndSlog(); // TODO b/64165549 Verify that mLock is not held before calling AMS methods synchronized (mService) { t.traceBegin("broadcastIntent-" + userId + "-" + intent.getAction()); final int result = mService.broadcastIntentLocked(null, null, null, intent, resolvedType, resultTo, resultCode, resultData, resultExtras, - requiredPermissions, null, null, appOp, bOptions, ordered, sticky, + requiredPermissions, null, null, appOp, bOptions, false, sticky, callingPid, callingUid, realCallingUid, realCallingPid, userId); t.traceEnd(); return result; diff --git a/services/core/java/com/android/server/pm/BroadcastHelper.java b/services/core/java/com/android/server/pm/BroadcastHelper.java index 9af2b3f6e2ae..278deb84996d 100644 --- a/services/core/java/com/android/server/pm/BroadcastHelper.java +++ b/services/core/java/com/android/server/pm/BroadcastHelper.java @@ -207,18 +207,8 @@ public final class BroadcastHelper { + intent.toShortString(false, true, false, false) + " " + intent.getExtras(), here); } - final boolean ordered; - if (mAmInternal.isModernQueueEnabled()) { - // When the modern broadcast stack is enabled, deliver all our - // broadcasts as unordered, since the modern stack has better - // support for sequencing cold-starts, and it supports - // delivering resultTo for non-ordered broadcasts - ordered = false; - } else { - ordered = (finishedReceiver != null); - } - mAmInternal.broadcastIntent( - intent, finishedReceiver, requiredPermissions, ordered, userId, + mAmInternal.broadcastIntentWithCallback( + intent, finishedReceiver, requiredPermissions, userId, broadcastAllowList == null ? null : broadcastAllowList.get(userId), filterExtrasForReceiver, bOptions); } diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java index 652cf18ed257..fde49d210f80 100644 --- a/services/core/java/com/android/server/power/Notifier.java +++ b/services/core/java/com/android/server/power/Notifier.java @@ -902,9 +902,9 @@ public class Notifier { } if (mActivityManagerInternal.isSystemReady()) { - final boolean ordered = !mActivityManagerInternal.isModernQueueEnabled(); - mActivityManagerInternal.broadcastIntent(mScreenOnIntent, mWakeUpBroadcastDone, - null, ordered, UserHandle.USER_ALL, null, null, mScreenOnOffOptions); + mActivityManagerInternal.broadcastIntentWithCallback(mScreenOnIntent, + mWakeUpBroadcastDone, null, UserHandle.USER_ALL, + null, null, mScreenOnOffOptions); } else { EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 2, 1); sendNextBroadcast(); @@ -927,9 +927,9 @@ public class Notifier { } if (mActivityManagerInternal.isSystemReady()) { - final boolean ordered = !mActivityManagerInternal.isModernQueueEnabled(); - mActivityManagerInternal.broadcastIntent(mScreenOffIntent, mGoToSleepBroadcastDone, - null, ordered, UserHandle.USER_ALL, null, null, mScreenOnOffOptions); + mActivityManagerInternal.broadcastIntentWithCallback(mScreenOffIntent, + mGoToSleepBroadcastDone, null, UserHandle.USER_ALL, + null, null, mScreenOnOffOptions); } else { EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 3, 1); sendNextBroadcast(); diff --git a/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java index ea1a68abe37b..7891661f6338 100644 --- a/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java @@ -1342,7 +1342,7 @@ public class UserControllerTest { @Override protected int broadcastIntent(Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, - String[] requiredPermissions, int appOp, Bundle bOptions, boolean ordered, + String[] requiredPermissions, int appOp, Bundle bOptions, boolean sticky, int callingPid, int callingUid, int realCallingUid, int realCallingPid, int userId) { Log.i(TAG, "broadcastIntentLocked " + intent); |