Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa59419b authored by Adam Bookatz's avatar Adam Bookatz
Browse files

Add back ActivityManagerService.onUserRemoved

ActivityManagerService.onUserRemoved was accidentally removed in
ag/4246926. This cl adds it back.

The part of onUserRemoved that told ActivityTaskManagerService that
the user had stopped (and thereby cleaned up ATMS) was retained, but
the additional actions of AMS.onUserRemoved - namely, telling
BatteryStatsService and UserController - were accidentally removed.
Consequently, those services were never told when a user was removed.

Bug: 140645064
Test: manual verification that profile is removed in  adb shell dumpsys activity users
Change-Id: I903b06ae68d583bdb326ad3b764a63d18b5555d8
parent 56669d83
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -80,6 +80,15 @@ public abstract class ActivityManagerInternal {
    public abstract boolean startIsolatedProcess(String entryPoint, String[] mainArgs,
            String processName, String abiOverride, int uid, Runnable crashHandler);

    /**
     * Called when a user has been deleted. This can happen during normal device usage
     * or just at startup, when partially removed users are purged. Any state persisted by the
     * ActivityManager should be purged now.
     *
     * @param userId The user being cleaned up.
     */
    public abstract void onUserRemoved(@UserIdInt int userId);

    /**
     * Kill foreground apps from the specified user.
     */
+9 −0
Original line number Diff line number Diff line
@@ -18778,6 +18778,15 @@ public class ActivityManagerService extends IActivityManager.Stub
                    processName, abiOverride, uid, crashHandler);
        }
        @Override
        public void onUserRemoved(@UserIdInt int userId) {
            // Clean up any ActivityTaskManager state (by telling it the user is stopped)
            mAtmInternal.onUserStopped(userId);
            // Clean up various services by removing the user
            mBatteryStatsService.onUserRemoved(userId);
            mUserController.onUserRemoved(userId);
        }
        @Override
        public void killForegroundAppsForUser(@UserIdInt int userId) {
            synchronized (ActivityManagerService.this) {
+2 −3
Original line number Diff line number Diff line
@@ -3890,9 +3890,8 @@ public class UserManagerService extends IUserManager.Stub {
                            new Thread() {
                                @Override
                                public void run() {
                                    // Clean up any ActivityTaskManager state
                                    LocalServices.getService(ActivityTaskManagerInternal.class)
                                            .onUserStopped(userId);
                                    LocalServices.getService(ActivityManagerInternal.class)
                                            .onUserRemoved(userId);
                                    removeUserState(userId);
                                }
                            }.start();
+2 −4
Original line number Diff line number Diff line
@@ -306,11 +306,9 @@ public abstract class ActivityTaskManagerInternal {
    public abstract void setAllowAppSwitches(@NonNull String type, int uid, int userId);

    /**
     * Called when a user has been deleted. This can happen during normal device usage
     * or just at startup, when partially removed users are purged. Any state persisted by the
     * ActivityManager should be purged now.
     * Called when a user has been stopped.
     *
     * @param userId The user being cleaned up.
     * @param userId The user being stopped.
     */
    public abstract void onUserStopped(int userId);
    public abstract boolean isGetTasksAllowed(String caller, int callingPid, int callingUid);