diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 47 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/UserController.java | 15 |
2 files changed, 57 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 10ba591640cc..b00676a15c0d 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1680,6 +1680,11 @@ public class ActivityManagerService extends IActivityManager.Stub PermissionManagerServiceInternal mPermissionManagerInt; private TestUtilityService mTestUtilityService; + // Packages which have received a (LOCKED_)BOOT_COMPLETED broadcast since + // the private space profile has been started + @GuardedBy("this") + private final ArraySet<String> mPrivateSpaceBootCompletedPackages = new ArraySet<String>(); + /** * Whether to force background check on all apps (for battery saver) or not. */ @@ -2307,6 +2312,19 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void onUserStopped(@NonNull TargetUser user) { mService.mBatteryStatsService.onCleanupUser(user.getUserIdentifier()); + + if (android.os.Flags.allowPrivateProfile() + && android.multiuser.Flags.enablePrivateSpaceFeatures()) { + final UserManagerInternal umInternal = + LocalServices.getService(UserManagerInternal.class); + UserInfo userInfo = umInternal.getUserInfo(user.getUserIdentifier()); + + if (userInfo != null && userInfo.isPrivateProfile()) { + synchronized (mService) { + mService.mPrivateSpaceBootCompletedPackages.clear(); + } + } + } } public ActivityManagerService getService() { @@ -5042,13 +5060,32 @@ public class ActivityManagerService extends IActivityManager.Stub } /** - * Send LOCKED_BOOT_COMPLETED and BOOT_COMPLETED to the package explicitly when unstopped + * Send LOCKED_BOOT_COMPLETED and BOOT_COMPLETED to the package explicitly when unstopped, + * or when the package first starts in private space */ private void maybeSendBootCompletedLocked(ProcessRecord app) { - if (!android.content.pm.Flags.stayStopped()) return; - // Nothing to do if it wasn't previously stopped - if (!app.wasForceStopped() && !app.getWindowProcessController().wasForceStopped()) { - return; + boolean sendBroadcast = false; + if (android.os.Flags.allowPrivateProfile() + && android.multiuser.Flags.enablePrivateSpaceFeatures()) { + final UserManagerInternal umInternal = + LocalServices.getService(UserManagerInternal.class); + UserInfo userInfo = umInternal.getUserInfo(app.userId); + + if (userInfo != null && userInfo.isPrivateProfile()) { + // Packages in private space get deferred boot completed whenever they start the + // first time since profile start + if (!mPrivateSpaceBootCompletedPackages.contains(app.info.packageName)) { + mPrivateSpaceBootCompletedPackages.add(app.info.packageName); + sendBroadcast = true; + } // else, stopped packages in private space may still hit the logic below + } + } + if (!sendBroadcast) { + if (!android.content.pm.Flags.stayStopped()) return; + // Nothing to do if it wasn't previously stopped + if (!app.wasForceStopped() && !app.getWindowProcessController().wasForceStopped()) { + return; + } } // Send LOCKED_BOOT_COMPLETED, if necessary diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index c2613bc47eb2..60a8b50feeab 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -671,6 +671,14 @@ class UserController implements Handler.Callback { } private void sendLockedBootCompletedBroadcast(IIntentReceiver receiver, @UserIdInt int userId) { + if (android.os.Flags.allowPrivateProfile() + && android.multiuser.Flags.enablePrivateSpaceFeatures()) { + final UserInfo userInfo = getUserInfo(userId); + if (userInfo != null && userInfo.isPrivateProfile()) { + Slogf.i(TAG, "Skipping LOCKED_BOOT_COMPLETED for private profile user #" + userId); + return; + } + } final Intent intent = new Intent(Intent.ACTION_LOCKED_BOOT_COMPLETED, null); intent.putExtra(Intent.EXTRA_USER_HANDLE, userId); intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT @@ -877,6 +885,13 @@ class UserController implements Handler.Callback { mHandler.obtainMessage(USER_UNLOCKED_MSG, userId, 0).sendToTarget(); + if (android.os.Flags.allowPrivateProfile() + && android.multiuser.Flags.enablePrivateSpaceFeatures()) { + if (userInfo.isPrivateProfile()) { + Slogf.i(TAG, "Skipping BOOT_COMPLETED for private profile user #" + userId); + return; + } + } Slogf.i(TAG, "Posting BOOT_COMPLETED user #" + userId); // Do not report secondary users, runtime restarts or first boot/upgrade if (userId == UserHandle.USER_SYSTEM |