Make sure userSwitchComplete is dispatched after screen is unfrozen.
At the end of user switch flow, registered UserSwitchObservers are informed that user switch is complete. This should be after screen is unfrozen. But if there is no password on the target user, keyguard is dismissed just before unfreezing the screen and unfreezing is postponed in handler. This causes the order to be as follows: dismissKeyguard -> dispatchUserSwitchComplete -> unfreezeScreen This CL makes sure the order is as follows: dismissKeyguard -> unfreezeScreen -> dispatchUserSwitchComplete Bug: 256576977 Test: atest FrameworksServicesTests:UserControllerTest Change-Id: Ia1952994a59796156a66c37a62090b3875bae4de
This commit is contained in:
@@ -2185,8 +2185,6 @@ class UserController implements Handler.Callback {
|
||||
mHandler.sendMessage(mHandler.obtainMessage(COMPLETE_USER_SWITCH_MSG, newUserId, 0));
|
||||
|
||||
uss.switching = false;
|
||||
mHandler.removeMessages(REPORT_USER_SWITCH_COMPLETE_MSG);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_COMPLETE_MSG, newUserId, 0));
|
||||
stopGuestOrEphemeralUserIfBackground(oldUserId);
|
||||
stopUserOnSwitchIfEnforced(oldUserId);
|
||||
if (oldUserId == UserHandle.USER_SYSTEM) {
|
||||
@@ -2200,21 +2198,22 @@ class UserController implements Handler.Callback {
|
||||
|
||||
@VisibleForTesting
|
||||
void completeUserSwitch(int newUserId) {
|
||||
if (isUserSwitchUiEnabled()) {
|
||||
// If there is no challenge set, dismiss the keyguard right away
|
||||
if (!mInjector.getKeyguardManager().isDeviceSecure(newUserId)) {
|
||||
// Wait until the keyguard is dismissed to unfreeze
|
||||
mInjector.dismissKeyguard(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
unfreezeScreen();
|
||||
}
|
||||
},
|
||||
"User Switch");
|
||||
return;
|
||||
} else {
|
||||
final boolean isUserSwitchUiEnabled = isUserSwitchUiEnabled();
|
||||
final Runnable runnable = () -> {
|
||||
if (isUserSwitchUiEnabled) {
|
||||
unfreezeScreen();
|
||||
}
|
||||
mHandler.removeMessages(REPORT_USER_SWITCH_COMPLETE_MSG);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(
|
||||
REPORT_USER_SWITCH_COMPLETE_MSG, newUserId, 0));
|
||||
};
|
||||
|
||||
// If there is no challenge set, dismiss the keyguard right away
|
||||
if (isUserSwitchUiEnabled && !mInjector.getKeyguardManager().isDeviceSecure(newUserId)) {
|
||||
// Wait until the keyguard is dismissed to unfreeze
|
||||
mInjector.dismissKeyguard(runnable, "User Switch");
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user