Merge "Add a guard on UserController to avoid user switches when not ready." into rvc-dev am: 340e55d091
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11817081 Change-Id: Ibb97b3ee2a385cc6fbc0083ac0b586a1984d9d7e
This commit is contained in:
@@ -348,6 +348,17 @@ class UserController implements Handler.Callback {
|
|||||||
@GuardedBy("mUserIdToUserJourneyMap")
|
@GuardedBy("mUserIdToUserJourneyMap")
|
||||||
private final SparseArray<UserJourneySession> mUserIdToUserJourneyMap = new SparseArray<>();
|
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) {
|
UserController(ActivityManagerService service) {
|
||||||
this(new Injector(service));
|
this(new Injector(service));
|
||||||
}
|
}
|
||||||
@@ -372,6 +383,7 @@ class UserController implements Handler.Callback {
|
|||||||
mUserSwitchUiEnabled = userSwitchUiEnabled;
|
mUserSwitchUiEnabled = userSwitchUiEnabled;
|
||||||
mMaxRunningUsers = maxRunningUsers;
|
mMaxRunningUsers = maxRunningUsers;
|
||||||
mDelayUserDataLocking = delayUserDataLocking;
|
mDelayUserDataLocking = delayUserDataLocking;
|
||||||
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1587,6 +1599,11 @@ class UserController implements Handler.Callback {
|
|||||||
}
|
}
|
||||||
boolean userSwitchUiEnabled;
|
boolean userSwitchUiEnabled;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
if (!mInitialized) {
|
||||||
|
Slog.e(TAG, "Cannot switch to User #" + targetUserId
|
||||||
|
+ ": UserController not ready yet");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mTargetUserId = targetUserId;
|
mTargetUserId = targetUserId;
|
||||||
userSwitchUiEnabled = mUserSwitchUiEnabled;
|
userSwitchUiEnabled = mUserSwitchUiEnabled;
|
||||||
}
|
}
|
||||||
@@ -2422,6 +2439,7 @@ class UserController implements Handler.Callback {
|
|||||||
pw.println(" mDelayUserDataLocking:" + mDelayUserDataLocking);
|
pw.println(" mDelayUserDataLocking:" + mDelayUserDataLocking);
|
||||||
pw.println(" mMaxRunningUsers:" + mMaxRunningUsers);
|
pw.println(" mMaxRunningUsers:" + mMaxRunningUsers);
|
||||||
pw.println(" mUserSwitchUiEnabled:" + mUserSwitchUiEnabled);
|
pw.println(" mUserSwitchUiEnabled:" + mUserSwitchUiEnabled);
|
||||||
|
pw.println(" mInitialized:" + mInitialized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user