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

Commit 6f96a44d authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Stop guest user on exiting, to conserve resources

Bug: 18672730
Change-Id: I17bc26ce2e10ceebeb18b75565daf21aa7df7774
parent 6bdbae07
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -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() {