diff options
| author | 2024-08-12 11:33:56 +0000 | |
|---|---|---|
| committer | 2024-08-12 20:43:52 +0000 | |
| commit | 322a96e6a69d6d6398cc2e1ab5616c979950ae0c (patch) | |
| tree | ab748bb4113eca96520cdc1dff0cdd3024a9bec8 | |
| parent | 254b854c491524c49cb4c291396deac7a12519b6 (diff) | |
Fix early call of UMS.removeUser causing system crash during boot.
When the removal of a user is initiated from shell command during boot,
before ActivityManager is ready, sending the user removal broadcasts throw an IllegalStateException causing FATAL Exception in system.
This CL adds a check to removeUser method to make sure ActivityManager
is ready before moving on.
Bug: 358267321
Change-Id: I51dfb73f2aada22b5cd56d734f36998cb17cfd50
Test: None
Flag: EXEMPT bugfix
| -rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 57d7d79b2392..2b639fa43c69 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -379,6 +379,10 @@ public class UserManagerService extends IUserManager.Stub { /** Count down latch to wait while boot user is not set.*/ private final CountDownLatch mBootUserLatch = new CountDownLatch(1); + + /** Current boot phase. */ + private @SystemService.BootPhase int mCurrentBootPhase; + /** * Internal non-parcelable wrapper for UserInfo that is not exposed to other system apps. */ @@ -968,6 +972,7 @@ public class UserManagerService extends IUserManager.Stub { @Override public void onBootPhase(int phase) { + mUms.mCurrentBootPhase = phase; if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { mUms.cleanupPartialUsers(); @@ -6204,6 +6209,11 @@ public class UserManagerService extends IUserManager.Stub { Slog.w(LOG_TAG, "Cannot remove user. " + restriction + " is enabled."); return false; } + if (mCurrentBootPhase < SystemService.PHASE_ACTIVITY_MANAGER_READY) { + Slog.w(LOG_TAG, "Cannot remove user, removeUser is called too early during boot. " + + "ActivityManager is not ready yet."); + return false; + } return removeUserWithProfilesUnchecked(userId); } |