Stop and remove the ephemeral user when it goes to background.
BUG: 24883058
Change-Id: I0e15487fafe08234cde5eebfb9f1d7b96fc7f9fe
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 43d4e77..20b1e60 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -432,6 +432,10 @@
synchronized (mService) {
mService.mStackSupervisor.removeUserLocked(userId);
}
+ // Remove the user if it is ephemeral.
+ if (getUserInfo(userId).isEphemeral()) {
+ mUserManager.removeUser(userId);
+ }
}
}
@@ -478,9 +482,9 @@
}
/**
- * Stops the guest user if it has gone to the background.
+ * Stops the guest or ephemeral user if it has gone to the background.
*/
- private void stopGuestUserIfBackground() {
+ private void stopGuestOrEphemeralUserIfBackground() {
synchronized (mService) {
final int num = mUserLru.size();
for (int i = 0; i < num; i++) {
@@ -492,7 +496,7 @@
continue;
}
UserInfo userInfo = getUserInfo(oldUserId);
- if (userInfo.isGuest()) {
+ if (userInfo.isGuest() || userInfo.isEphemeral()) {
// This is a user to be stopped.
stopUsersLocked(oldUserId, true, null);
break;
@@ -918,7 +922,7 @@
mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_COMPLETE_MSG,
newUserId, 0));
}
- stopGuestUserIfBackground();
+ stopGuestOrEphemeralUserIfBackground();
stopBackgroundUsersIfEnforced(oldUserId);
}