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

Commit f2811097 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

Keep media sessions for stopping user until the stopping is completed

If a user is quickly *switched back*, the user can be started again
without cleaning up its processes, while the onStopUser() is called in
the middle. It's because onStopUser() is for 'stopping is started' but
it may be canceled if the user is started again quickly.

Bug: 154965421
Test: Manual test on AAE emulator with Android-Q, and Pixel 3a XL with Android-R.
Change-Id: I6e51f865dd9e97edd8a465eeba02966b242525b2
parent e7f3897b
Loading
Loading
Loading
Loading
+2 −5
Original line number Original line Diff line number Diff line
@@ -334,13 +334,10 @@ public class MediaSessionService extends SystemService implements Monitor {
        updateUser();
        updateUser();
    }
    }


    // Called when the user with the userId is removed.
    @Override
    @Override
    public void onStopUser(int userId) {
    public void onCleanupUser(int userId) {
        if (DEBUG) Log.d(TAG, "onStopUser: " + userId);
        if (DEBUG) Log.d(TAG, "onCleanupUser: " + userId);
        synchronized (mLock) {
        synchronized (mLock) {
            // TODO: Also handle removing user in updateUser() because adding/switching user is
            //       handled in updateUser().
            FullUserRecord user = getFullUserRecordLocked(userId);
            FullUserRecord user = getFullUserRecordLocked(userId);
            if (user != null) {
            if (user != null) {
                if (user.mFullUserId == userId) {
                if (user.mFullUserId == userId) {