Merge "Stop guest user on exiting, to conserve resources" into lmp-mr1-dev

This commit is contained in:
Amith Yamasani
2014-12-10 22:54:27 +00:00
committed by Android (Google) Code Review

View File

@@ -18972,6 +18972,31 @@ public final class ActivityManagerService extends ActivityManagerNative
} }
mUserSwitchObservers.finishBroadcast(); 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() { void scheduleStartProfilesLocked() {