diff options
| author | 2017-10-25 14:23:43 -0700 | |
|---|---|---|
| committer | 2017-10-25 14:23:43 -0700 | |
| commit | bc77f8889e2158cefeddebaccb26e0196851004f (patch) | |
| tree | a72f58fe212139c1fbc06e45cc71c0a5290f21ff | |
| parent | 0e0621a46bb23de1d2dea0902a133d0a1c0ba977 (diff) | |
Fixed issue with MAX_RUNNING_USERS
Previously the user being switched could remain running if primary user
had work profile, due to counter being decremented twice.
Test: manual switch with work profiles and without + cts
Bug: 67091825
Change-Id: I61212c6407fecefa0094c6265dee6f3184d95701
| -rw-r--r-- | services/core/java/com/android/server/am/UserController.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index 4aa8adb9dc78..a0c5cfaa7908 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -250,21 +250,21 @@ class UserController implements Handler.Callback { } void stopRunningUsersLU(int maxRunningUsers) { - int num = mUserLru.size(); + int currentlyRunning = mUserLru.size(); int i = 0; - while (num > maxRunningUsers && i < mUserLru.size()) { + while (currentlyRunning > maxRunningUsers && i < mUserLru.size()) { Integer oldUserId = mUserLru.get(i); UserState oldUss = mStartedUsers.get(oldUserId); if (oldUss == null) { // Shouldn't happen, but be sane if it does. mUserLru.remove(i); - num--; + currentlyRunning--; continue; } if (oldUss.state == UserState.STATE_STOPPING || oldUss.state == UserState.STATE_SHUTDOWN) { // This user is already stopping, doesn't count. - num--; + currentlyRunning--; i++; continue; } @@ -272,16 +272,15 @@ class UserController implements Handler.Callback { // Owner/System user and current user can't be stopped. We count it as running // when it is not a pure system user. if (UserInfo.isSystemOnly(oldUserId)) { - num--; + currentlyRunning--; } i++; continue; } // This is a user to be stopped. - if (stopUsersLU(oldUserId, false, null) != USER_OP_SUCCESS) { - num--; + if (stopUsersLU(oldUserId, false, null) == USER_OP_SUCCESS) { + currentlyRunning--; } - num--; i++; } } |