From f281109786cfb7b5d1cbfd8a9e21088ee5c87348 Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Wed, 20 May 2020 05:40:18 +0900 Subject: [PATCH] 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 --- .../java/com/android/server/media/MediaSessionService.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 5bd4b2029e7b6..2d719aed3ff94 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -334,13 +334,10 @@ public class MediaSessionService extends SystemService implements Monitor { updateUser(); } - // Called when the user with the userId is removed. @Override - public void onStopUser(int userId) { - if (DEBUG) Log.d(TAG, "onStopUser: " + userId); + public void onCleanupUser(int userId) { + if (DEBUG) Log.d(TAG, "onCleanupUser: " + userId); synchronized (mLock) { - // TODO: Also handle removing user in updateUser() because adding/switching user is - // handled in updateUser(). FullUserRecord user = getFullUserRecordLocked(userId); if (user != null) { if (user.mFullUserId == userId) {