Loading services/core/java/com/android/server/am/UserController.java +15 −9 Original line number Diff line number Diff line Loading @@ -425,6 +425,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") @VisibleForTesting List<Integer> getRunningUsersLU() { ArrayList<Integer> runningUsers = new ArrayList<>(); for (Integer userId : mUserLru) { Loading @@ -450,7 +451,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") void stopRunningUsersLU(int maxRunningUsers) { private void stopRunningUsersLU(int maxRunningUsers) { List<Integer> currentlyRunning = getRunningUsersLU(); Iterator<Integer> iterator = currentlyRunning.iterator(); while (currentlyRunning.size() > maxRunningUsers && iterator.hasNext()) { Loading Loading @@ -616,7 +617,7 @@ class UserController implements Handler.Callback { * Step from {@link UserState#STATE_RUNNING_UNLOCKING} to * {@link UserState#STATE_RUNNING_UNLOCKED}. */ void finishUserUnlocked(final UserState uss) { private void finishUserUnlocked(final UserState uss) { final int userId = uss.mHandle.getIdentifier(); EventLog.writeEvent(EventLogTags.UC_FINISH_USER_UNLOCKED, userId); // Only keep marching forward if user is actually unlocked Loading Loading @@ -911,7 +912,7 @@ class UserController implements Handler.Callback { private void stopSingleUserLU(final int userId, boolean allowDelayedLocking, final IStopUserCallback stopUserCallback, KeyEvictedCallback keyEvictedCallback) { if (DEBUG_MU) Slogf.i(TAG, "stopSingleUserLocked userId=" + userId); Slogf.i(TAG, "stopSingleUserLU userId=" + userId); final UserState uss = mStartedUsers.get(userId); if (uss == null) { // User is not started // If mDelayUserDataLocking is set and allowDelayedLocking is not set, we need to lock Loading Loading @@ -1004,7 +1005,7 @@ class UserController implements Handler.Callback { } } void finishUserStopping(final int userId, final UserState uss, private void finishUserStopping(final int userId, final UserState uss, final boolean allowDelayedLocking) { EventLog.writeEvent(EventLogTags.UC_FINISH_USER_STOPPING, userId); synchronized (mLock) { Loading Loading @@ -1045,6 +1046,7 @@ class UserController implements Handler.Callback { Binder.getCallingPid(), userId); } @VisibleForTesting void finishUserStopped(UserState uss, boolean allowDelayedLocking) { final int userId = uss.mHandle.getIdentifier(); if (DEBUG_MU) { Loading Loading @@ -1268,7 +1270,7 @@ class UserController implements Handler.Callback { }); } void startProfiles() { private void startProfiles() { int currentUserId = getCurrentUserId(); if (DEBUG_MU) Slogf.i(TAG, "startProfilesLocked"); List<UserInfo> profiles = mInjector.getUserManager().getProfiles( Loading Loading @@ -1321,6 +1323,7 @@ class UserController implements Handler.Callback { return startUserNoChecks(userId, /* foreground= */ false, /* unlockListener= */ null); } @VisibleForTesting boolean startUser(final @UserIdInt int userId, final boolean foreground) { return startUser(userId, foreground, null); } Loading Loading @@ -1783,6 +1786,7 @@ class UserController implements Handler.Callback { } /** Called on handler thread */ @VisibleForTesting void dispatchUserSwitchComplete(@UserIdInt int userId) { mInjector.getWindowManager().setSwitchingUser(false); final int observerCount = mUserSwitchObservers.beginBroadcast(); Loading Loading @@ -1856,6 +1860,7 @@ class UserController implements Handler.Callback { } } @VisibleForTesting void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) { final TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("dispatchUserSwitch-" + oldUserId + "-to-" + newUserId); Loading Loading @@ -1916,13 +1921,14 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) { private void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) { mCurWaitingUserSwitchCallbacks = null; mHandler.removeMessages(USER_SWITCH_TIMEOUT_MSG); mHandler.sendMessage(mHandler.obtainMessage(CONTINUE_USER_SWITCH_MSG, oldUserId, newUserId, uss)); } @VisibleForTesting void continueUserSwitch(UserState uss, int oldUserId, int newUserId) { final TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("continueUserSwitch-" + oldUserId + "-to-" + newUserId); Loading Loading @@ -2373,7 +2379,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") UserInfo getCurrentUserLU() { private UserInfo getCurrentUserLU() { int userId = getCurrentOrTargetUserIdLU(); return getUserInfo(userId); } Loading @@ -2385,12 +2391,12 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") int getCurrentOrTargetUserIdLU() { private int getCurrentOrTargetUserIdLU() { return mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId; } @GuardedBy("mLock") int getCurrentUserIdLU() { private int getCurrentUserIdLU() { return mCurrentUserId; } Loading services/core/java/com/android/server/pm/UserManagerService.java +16 −9 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ import com.android.server.am.UserState; import com.android.server.pm.UserManagerInternal.UserLifecycleListener; import com.android.server.pm.UserManagerInternal.UserRestrictionsListener; import com.android.server.storage.DeviceStorageMonitorInternal; import com.android.server.utils.Slogf; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; Loading Loading @@ -727,7 +728,7 @@ public class UserManagerService extends IUserManager.Stub { } /* Prunes out any partially created or partially removed users. */ void cleanupPartialUsers() { private void cleanupPartialUsers() { ArrayList<UserInfo> partials = new ArrayList<>(); synchronized (mUsersLock) { final int userSize = mUsers.size(); Loading Loading @@ -755,7 +756,7 @@ public class UserManagerService extends IUserManager.Stub { * Removes any pre-created users from the system. Should be invoked after OTAs, to ensure * pre-created users are not stale. New pre-created pool can be re-created after the update. */ void cleanupPreCreatedUsers() { private void cleanupPreCreatedUsers() { final ArrayList<UserInfo> preCreatedUsers; synchronized (mUsersLock) { final int userSize = mUsers.size(); Loading Loading @@ -1213,6 +1214,10 @@ public class UserManagerService extends IUserManager.Stub { private void logQuietModeEnabled(@UserIdInt int userId, boolean enableQuietMode, @Nullable String callingPackage) { Slogf.i(LOG_TAG, "requestQuietModeEnabled called by package %s, with enableQuietMode %b.", callingPackage, enableQuietMode); UserData userData; synchronized (mUsersLock) { userData = getUserDataLU(userId); Loading Loading @@ -2293,13 +2298,13 @@ public class UserManagerService extends IUserManager.Stub { // Package private for the inner class. @GuardedBy("mRestrictionsLock") void applyUserRestrictionsLR(@UserIdInt int userId) { private void applyUserRestrictionsLR(@UserIdInt int userId) { updateUserRestrictionsInternalLR(null, userId); } @GuardedBy("mRestrictionsLock") // Package private for the inner class. void applyUserRestrictionsForAllUsersLR() { private void applyUserRestrictionsForAllUsersLR() { if (DBG) { debug("applyUserRestrictionsForAllUsersLR"); } Loading Loading @@ -2900,8 +2905,7 @@ public class UserManagerService extends IUserManager.Stub { } @GuardedBy("mUsersLock") @VisibleForTesting void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps, private void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps, @NonNull ArrayMap<String, UserTypeDetails> userTypes, final int formerUserTypeVersion, @NonNull Set<Integer> userIdsToWrite) { Loading Loading @@ -3880,6 +3884,7 @@ public class UserManagerService extends IUserManager.Stub { } /** Checks that the flags do not contain mutually exclusive types/properties. */ @VisibleForTesting static boolean checkUserTypeConsistency(@UserInfoFlag int flags) { // Mask to check that flags don't refer to multiple user types. final int userTypeFlagMask = UserInfo.FLAG_GUEST | UserInfo.FLAG_DEMO Loading Loading @@ -4186,6 +4191,7 @@ public class UserManagerService extends IUserManager.Stub { return false; } Slog.i(LOG_TAG, "Removing user " + userId); addRemovingUserIdLocked(userId); } Loading Loading @@ -4308,8 +4314,8 @@ public class UserManagerService extends IUserManager.Stub { } } void finishRemoveUser(final @UserIdInt int userId) { if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userId); private void finishRemoveUser(final @UserIdInt int userId) { Slog.i(LOG_TAG, "finishRemoveUser " + userId); UserInfo user; synchronized (mUsersLock) { Loading Loading @@ -4368,6 +4374,7 @@ public class UserManagerService extends IUserManager.Stub { } private void removeUserState(final @UserIdInt int userId) { Slog.i(LOG_TAG, "Removing user state of user " + userId); try { mContext.getSystemService(StorageManager.class).destroyUserKey(userId); } catch (IllegalStateException e) { Loading Loading @@ -4991,7 +4998,7 @@ public class UserManagerService extends IUserManager.Stub { (new Shell()).exec(this, in, out, err, args, callback, resultReceiver); } int onShellCommand(Shell shell, String cmd) { private int onShellCommand(Shell shell, String cmd) { if (cmd == null) { return shell.handleDefaultCommands(cmd); } Loading Loading
services/core/java/com/android/server/am/UserController.java +15 −9 Original line number Diff line number Diff line Loading @@ -425,6 +425,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") @VisibleForTesting List<Integer> getRunningUsersLU() { ArrayList<Integer> runningUsers = new ArrayList<>(); for (Integer userId : mUserLru) { Loading @@ -450,7 +451,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") void stopRunningUsersLU(int maxRunningUsers) { private void stopRunningUsersLU(int maxRunningUsers) { List<Integer> currentlyRunning = getRunningUsersLU(); Iterator<Integer> iterator = currentlyRunning.iterator(); while (currentlyRunning.size() > maxRunningUsers && iterator.hasNext()) { Loading Loading @@ -616,7 +617,7 @@ class UserController implements Handler.Callback { * Step from {@link UserState#STATE_RUNNING_UNLOCKING} to * {@link UserState#STATE_RUNNING_UNLOCKED}. */ void finishUserUnlocked(final UserState uss) { private void finishUserUnlocked(final UserState uss) { final int userId = uss.mHandle.getIdentifier(); EventLog.writeEvent(EventLogTags.UC_FINISH_USER_UNLOCKED, userId); // Only keep marching forward if user is actually unlocked Loading Loading @@ -911,7 +912,7 @@ class UserController implements Handler.Callback { private void stopSingleUserLU(final int userId, boolean allowDelayedLocking, final IStopUserCallback stopUserCallback, KeyEvictedCallback keyEvictedCallback) { if (DEBUG_MU) Slogf.i(TAG, "stopSingleUserLocked userId=" + userId); Slogf.i(TAG, "stopSingleUserLU userId=" + userId); final UserState uss = mStartedUsers.get(userId); if (uss == null) { // User is not started // If mDelayUserDataLocking is set and allowDelayedLocking is not set, we need to lock Loading Loading @@ -1004,7 +1005,7 @@ class UserController implements Handler.Callback { } } void finishUserStopping(final int userId, final UserState uss, private void finishUserStopping(final int userId, final UserState uss, final boolean allowDelayedLocking) { EventLog.writeEvent(EventLogTags.UC_FINISH_USER_STOPPING, userId); synchronized (mLock) { Loading Loading @@ -1045,6 +1046,7 @@ class UserController implements Handler.Callback { Binder.getCallingPid(), userId); } @VisibleForTesting void finishUserStopped(UserState uss, boolean allowDelayedLocking) { final int userId = uss.mHandle.getIdentifier(); if (DEBUG_MU) { Loading Loading @@ -1268,7 +1270,7 @@ class UserController implements Handler.Callback { }); } void startProfiles() { private void startProfiles() { int currentUserId = getCurrentUserId(); if (DEBUG_MU) Slogf.i(TAG, "startProfilesLocked"); List<UserInfo> profiles = mInjector.getUserManager().getProfiles( Loading Loading @@ -1321,6 +1323,7 @@ class UserController implements Handler.Callback { return startUserNoChecks(userId, /* foreground= */ false, /* unlockListener= */ null); } @VisibleForTesting boolean startUser(final @UserIdInt int userId, final boolean foreground) { return startUser(userId, foreground, null); } Loading Loading @@ -1783,6 +1786,7 @@ class UserController implements Handler.Callback { } /** Called on handler thread */ @VisibleForTesting void dispatchUserSwitchComplete(@UserIdInt int userId) { mInjector.getWindowManager().setSwitchingUser(false); final int observerCount = mUserSwitchObservers.beginBroadcast(); Loading Loading @@ -1856,6 +1860,7 @@ class UserController implements Handler.Callback { } } @VisibleForTesting void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) { final TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("dispatchUserSwitch-" + oldUserId + "-to-" + newUserId); Loading Loading @@ -1916,13 +1921,14 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) { private void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) { mCurWaitingUserSwitchCallbacks = null; mHandler.removeMessages(USER_SWITCH_TIMEOUT_MSG); mHandler.sendMessage(mHandler.obtainMessage(CONTINUE_USER_SWITCH_MSG, oldUserId, newUserId, uss)); } @VisibleForTesting void continueUserSwitch(UserState uss, int oldUserId, int newUserId) { final TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("continueUserSwitch-" + oldUserId + "-to-" + newUserId); Loading Loading @@ -2373,7 +2379,7 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") UserInfo getCurrentUserLU() { private UserInfo getCurrentUserLU() { int userId = getCurrentOrTargetUserIdLU(); return getUserInfo(userId); } Loading @@ -2385,12 +2391,12 @@ class UserController implements Handler.Callback { } @GuardedBy("mLock") int getCurrentOrTargetUserIdLU() { private int getCurrentOrTargetUserIdLU() { return mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId; } @GuardedBy("mLock") int getCurrentUserIdLU() { private int getCurrentUserIdLU() { return mCurrentUserId; } Loading
services/core/java/com/android/server/pm/UserManagerService.java +16 −9 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ import com.android.server.am.UserState; import com.android.server.pm.UserManagerInternal.UserLifecycleListener; import com.android.server.pm.UserManagerInternal.UserRestrictionsListener; import com.android.server.storage.DeviceStorageMonitorInternal; import com.android.server.utils.Slogf; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; Loading Loading @@ -727,7 +728,7 @@ public class UserManagerService extends IUserManager.Stub { } /* Prunes out any partially created or partially removed users. */ void cleanupPartialUsers() { private void cleanupPartialUsers() { ArrayList<UserInfo> partials = new ArrayList<>(); synchronized (mUsersLock) { final int userSize = mUsers.size(); Loading Loading @@ -755,7 +756,7 @@ public class UserManagerService extends IUserManager.Stub { * Removes any pre-created users from the system. Should be invoked after OTAs, to ensure * pre-created users are not stale. New pre-created pool can be re-created after the update. */ void cleanupPreCreatedUsers() { private void cleanupPreCreatedUsers() { final ArrayList<UserInfo> preCreatedUsers; synchronized (mUsersLock) { final int userSize = mUsers.size(); Loading Loading @@ -1213,6 +1214,10 @@ public class UserManagerService extends IUserManager.Stub { private void logQuietModeEnabled(@UserIdInt int userId, boolean enableQuietMode, @Nullable String callingPackage) { Slogf.i(LOG_TAG, "requestQuietModeEnabled called by package %s, with enableQuietMode %b.", callingPackage, enableQuietMode); UserData userData; synchronized (mUsersLock) { userData = getUserDataLU(userId); Loading Loading @@ -2293,13 +2298,13 @@ public class UserManagerService extends IUserManager.Stub { // Package private for the inner class. @GuardedBy("mRestrictionsLock") void applyUserRestrictionsLR(@UserIdInt int userId) { private void applyUserRestrictionsLR(@UserIdInt int userId) { updateUserRestrictionsInternalLR(null, userId); } @GuardedBy("mRestrictionsLock") // Package private for the inner class. void applyUserRestrictionsForAllUsersLR() { private void applyUserRestrictionsForAllUsersLR() { if (DBG) { debug("applyUserRestrictionsForAllUsersLR"); } Loading Loading @@ -2900,8 +2905,7 @@ public class UserManagerService extends IUserManager.Stub { } @GuardedBy("mUsersLock") @VisibleForTesting void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps, private void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps, @NonNull ArrayMap<String, UserTypeDetails> userTypes, final int formerUserTypeVersion, @NonNull Set<Integer> userIdsToWrite) { Loading Loading @@ -3880,6 +3884,7 @@ public class UserManagerService extends IUserManager.Stub { } /** Checks that the flags do not contain mutually exclusive types/properties. */ @VisibleForTesting static boolean checkUserTypeConsistency(@UserInfoFlag int flags) { // Mask to check that flags don't refer to multiple user types. final int userTypeFlagMask = UserInfo.FLAG_GUEST | UserInfo.FLAG_DEMO Loading Loading @@ -4186,6 +4191,7 @@ public class UserManagerService extends IUserManager.Stub { return false; } Slog.i(LOG_TAG, "Removing user " + userId); addRemovingUserIdLocked(userId); } Loading Loading @@ -4308,8 +4314,8 @@ public class UserManagerService extends IUserManager.Stub { } } void finishRemoveUser(final @UserIdInt int userId) { if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userId); private void finishRemoveUser(final @UserIdInt int userId) { Slog.i(LOG_TAG, "finishRemoveUser " + userId); UserInfo user; synchronized (mUsersLock) { Loading Loading @@ -4368,6 +4374,7 @@ public class UserManagerService extends IUserManager.Stub { } private void removeUserState(final @UserIdInt int userId) { Slog.i(LOG_TAG, "Removing user state of user " + userId); try { mContext.getSystemService(StorageManager.class).destroyUserKey(userId); } catch (IllegalStateException e) { Loading Loading @@ -4991,7 +4998,7 @@ public class UserManagerService extends IUserManager.Stub { (new Shell()).exec(this, in, out, err, args, callback, resultReceiver); } int onShellCommand(Shell shell, String cmd) { private int onShellCommand(Shell shell, String cmd) { if (cmd == null) { return shell.handleDefaultCommands(cmd); } Loading