diff options
| -rwxr-xr-x | services/core/java/com/android/server/am/ActivityManagerService.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 1227148421af..e0f8aa6a676b 100755 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18969,6 +18969,31 @@ public final class ActivityManagerService extends ActivityManagerNative } mUserSwitchObservers.finishBroadcast(); } + stopGuestUserIfBackground(); + } + + /** + * Stops the guest user if it has gone to the background. + */ + private void stopGuestUserIfBackground() { + synchronized (this) { + final int num = mUserLru.size(); + for (int i = 0; i < num; i++) { + Integer oldUserId = mUserLru.get(i); + UserStartedState oldUss = mStartedUsers.get(oldUserId); + if (oldUserId == UserHandle.USER_OWNER || oldUserId == mCurrentUserId + || oldUss.mState == UserStartedState.STATE_STOPPING + || oldUss.mState == UserStartedState.STATE_SHUTDOWN) { + continue; + } + UserInfo userInfo = mUserManager.getUserInfo(oldUserId); + if (userInfo.isGuest()) { + // This is a user to be stopped. + stopUserLocked(oldUserId, null); + break; + } + } + } } void scheduleStartProfilesLocked() { |