summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aaron Liu <aaronjli@google.com> 2022-04-26 18:15:53 +0000
committer Aaron Liu <aaronjli@google.com> 2022-04-26 18:19:14 +0000
commit74b0c462edc5e9da45a8be707fd6ce7dedbed8b0 (patch)
treeeade7c8c5c83a3fd1b8ee18600ec64d516f20fd3
parent3d790a167398321eca2b462df83bfc7422b0b91f (diff)
[Bouncer] fix user switch race condition
When switching from user with auth i.e. password to a user that has swipe to unlock can experience a race condition where bouncer is not dismissed when switching users from bouncer. This happens when switching users very quickly. This can be resolved by changing our subscription to when a user changes. Bug: 228901381 Test: Unit test and manual test Change-Id: I7df7af986094f4719d39ee5d63ceafea8a812493
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java6
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java10
3 files changed, 14 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java
index 239b478949d2..804d14681812 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java
@@ -68,12 +68,6 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
private final KeyguardUpdateMonitorCallback mUpdateCallback =
new KeyguardUpdateMonitorCallback() {
@Override
- public void onUserSwitchComplete(int userId) {
- mKeyguardSecurityContainerController.showPrimarySecurityScreen(
- false /* turning off */);
- }
-
- @Override
public void onTrustGrantedWithFlags(int flags, int userId) {
if (userId != KeyguardUpdateMonitor.getCurrentUser()) return;
boolean bouncerVisible = mView.isVisibleToUser();
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
index ce4aad882df9..28a3dbbf6c83 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
@@ -97,6 +97,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
+ private UserSwitcherController.UserSwitchCallback mUserSwitchCallback =
+ () -> showPrimarySecurityScreen(false);
@VisibleForTesting
final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
@@ -295,6 +297,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mView.setSwipeListener(mSwipeListener);
mView.addMotionEventListener(mGlobalTouchListener);
mConfigurationController.addCallback(mConfigurationListener);
+ mUserSwitcherController.addUserSwitchCallback(mUserSwitchCallback);
}
@Override
@@ -302,6 +305,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mConfigurationController.removeCallback(mConfigurationListener);
mView.removeMotionEventListener(mGlobalTouchListener);
+ mUserSwitcherController.removeUserSwitchCallback(mUserSwitchCallback);
}
/** */
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
index a819a7a0f815..143f9956b834 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
@@ -287,4 +287,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
verify(mView).initMode(MODE_DEFAULT, mGlobalSettings, mFalsingManager,
mUserSwitcherController);
}
+
+ @Test
+ public void addUserSwitchCallback() {
+ mKeyguardSecurityContainerController.onViewAttached();
+ verify(mUserSwitcherController)
+ .addUserSwitchCallback(any(UserSwitcherController.UserSwitchCallback.class));
+ mKeyguardSecurityContainerController.onViewDetached();
+ verify(mUserSwitcherController)
+ .removeUserSwitchCallback(any(UserSwitcherController.UserSwitchCallback.class));
+ }
}