Merge "[Bouncer] fix user switch race condition" into tm-dev

This commit is contained in:
Aaron Liu
2022-04-29 18:32:50 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 6 deletions

View File

@@ -67,12 +67,6 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
private final KeyguardUpdateMonitorCallback mUpdateCallback = private final KeyguardUpdateMonitorCallback mUpdateCallback =
new KeyguardUpdateMonitorCallback() { new KeyguardUpdateMonitorCallback() {
@Override
public void onUserSwitchComplete(int userId) {
mKeyguardSecurityContainerController.showPrimarySecurityScreen(
false /* turning off */);
}
@Override @Override
public void onTrustGrantedWithFlags(int flags, int userId) { public void onTrustGrantedWithFlags(int flags, int userId) {
if (userId != KeyguardUpdateMonitor.getCurrentUser()) return; if (userId != KeyguardUpdateMonitor.getCurrentUser()) return;

View File

@@ -97,6 +97,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED; private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid; private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
private UserSwitcherController.UserSwitchCallback mUserSwitchCallback =
() -> showPrimarySecurityScreen(false);
@VisibleForTesting @VisibleForTesting
final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() { final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
@@ -295,6 +297,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mView.setSwipeListener(mSwipeListener); mView.setSwipeListener(mSwipeListener);
mView.addMotionEventListener(mGlobalTouchListener); mView.addMotionEventListener(mGlobalTouchListener);
mConfigurationController.addCallback(mConfigurationListener); mConfigurationController.addCallback(mConfigurationListener);
mUserSwitcherController.addUserSwitchCallback(mUserSwitchCallback);
} }
@Override @Override
@@ -302,6 +305,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); mUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mConfigurationController.removeCallback(mConfigurationListener); mConfigurationController.removeCallback(mConfigurationListener);
mView.removeMotionEventListener(mGlobalTouchListener); mView.removeMotionEventListener(mGlobalTouchListener);
mUserSwitcherController.removeUserSwitchCallback(mUserSwitchCallback);
} }
/** */ /** */

View File

@@ -287,4 +287,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
verify(mView).initMode(MODE_DEFAULT, mGlobalSettings, mFalsingManager, verify(mView).initMode(MODE_DEFAULT, mGlobalSettings, mFalsingManager,
mUserSwitcherController); mUserSwitcherController);
} }
@Test
public void addUserSwitchCallback() {
mKeyguardSecurityContainerController.onViewAttached();
verify(mUserSwitcherController)
.addUserSwitchCallback(any(UserSwitcherController.UserSwitchCallback.class));
mKeyguardSecurityContainerController.onViewDetached();
verify(mUserSwitcherController)
.removeUserSwitchCallback(any(UserSwitcherController.UserSwitchCallback.class));
}
} }