Merge "Add a guard on UserController to avoid user switches when not ready." into rvc-dev am: 340e55d091 am: 527c14b4cc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11817081 Change-Id: I52586273362f452a9a9957d84cca8a4bb25af8b3
This commit is contained in:
@@ -348,6 +348,17 @@ class UserController implements Handler.Callback {
|
||||
@GuardedBy("mUserIdToUserJourneyMap")
|
||||
private final SparseArray<UserJourneySession> mUserIdToUserJourneyMap = new SparseArray<>();
|
||||
|
||||
/**
|
||||
* Sets on {@link #setInitialConfig(boolean, int, boolean)}, which is called by
|
||||
* {@code ActivityManager} when the system is started.
|
||||
*
|
||||
* <p>It's useful to ignore external operations (i.e., originated outside {@code system_server},
|
||||
* like from {@code adb shell am switch-user})) that could happen before such call is made and
|
||||
* the system is ready.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
private boolean mInitialized;
|
||||
|
||||
UserController(ActivityManagerService service) {
|
||||
this(new Injector(service));
|
||||
}
|
||||
@@ -372,6 +383,7 @@ class UserController implements Handler.Callback {
|
||||
mUserSwitchUiEnabled = userSwitchUiEnabled;
|
||||
mMaxRunningUsers = maxRunningUsers;
|
||||
mDelayUserDataLocking = delayUserDataLocking;
|
||||
mInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1587,6 +1599,11 @@ class UserController implements Handler.Callback {
|
||||
}
|
||||
boolean userSwitchUiEnabled;
|
||||
synchronized (mLock) {
|
||||
if (!mInitialized) {
|
||||
Slog.e(TAG, "Cannot switch to User #" + targetUserId
|
||||
+ ": UserController not ready yet");
|
||||
return false;
|
||||
}
|
||||
mTargetUserId = targetUserId;
|
||||
userSwitchUiEnabled = mUserSwitchUiEnabled;
|
||||
}
|
||||
@@ -2422,6 +2439,7 @@ class UserController implements Handler.Callback {
|
||||
pw.println(" mDelayUserDataLocking:" + mDelayUserDataLocking);
|
||||
pw.println(" mMaxRunningUsers:" + mMaxRunningUsers);
|
||||
pw.println(" mUserSwitchUiEnabled:" + mUserSwitchUiEnabled);
|
||||
pw.println(" mInitialized:" + mInitialized);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user