diff options
| author | 2024-04-11 19:19:34 +0000 | |
|---|---|---|
| committer | 2024-04-11 19:22:07 +0000 | |
| commit | 3f4b04b81c4b59b17a0407f7d594feaf7ddd04fb (patch) | |
| tree | 15a3953dcb9a839b03ab24b8cbb37185fbcc4275 | |
| parent | 6c27c89c4db4cf9959e0d1ee41f15b3ed39f414f (diff) | |
Check KeyguardTransitionInteractor for the current keyguard state
Don't check KeyguardBypassController or the AlternateBouncerInteractor
for whether the alternate bouncer is visible. It's possible that we
just started transitioning away from the alternate bouncer, but those
states are already reporting isAltBouncerShowing=false. Instead, it's
more robust to check whether we're currently in the KeyguardTransition
state for the alternate bouncer which will include when we're
transitioning away from the AlternateBouncer but haven't finished into
the next state (for example, GONE).
Test: atest BiometricsUnlockControllerTest
Fixes: 332885570
Flag: None
Change-Id: Iea1496f6ba4be62eef57ba2040b7b43c7e730126
2 files changed, 27 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index 8b7b348ede76..79e6a0aa9c8c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -67,6 +67,8 @@ import com.android.systemui.util.time.SystemClock; import dagger.Lazy; +import kotlinx.coroutines.ExperimentalCoroutinesApi; + import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -77,8 +79,6 @@ import java.util.Set; import javax.inject.Inject; -import kotlinx.coroutines.ExperimentalCoroutinesApi; - /** * Controller which coordinates all the biometric unlocking actions with the UI. */ @@ -183,6 +183,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final SystemClock mSystemClock; private final boolean mOrderUnlockAndWake; private final Lazy<SelectedUserInteractor> mSelectedUserInteractor; + private final KeyguardTransitionInteractor mKeyguardTransitionInteractor; private long mLastFpFailureUptimeMillis; private int mNumConsecutiveFpFailures; @@ -323,6 +324,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mOrderUnlockAndWake = resources.getBoolean( com.android.internal.R.bool.config_orderUnlockAndWake); mSelectedUserInteractor = selectedUserInteractor; + mKeyguardTransitionInteractor = keyguardTransitionInteractor; javaAdapter.alwaysCollectFlow( keyguardTransitionInteractor.getStartedKeyguardTransitionStep(), this::consumeTransitionStepOnStartedKeyguardState); @@ -665,7 +667,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp } if (isKeyguardShowing) { if ((mKeyguardViewController.primaryBouncerIsOrWillBeShowing() - || mKeyguardBypassController.getAltBouncerShowing()) && unlockingAllowed) { + || mKeyguardTransitionInteractor.getCurrentState() + == KeyguardState.ALTERNATE_BOUNCER) && unlockingAllowed) { return MODE_DISMISS_BOUNCER; } else if (unlockingAllowed && bypass) { return MODE_UNLOCK_COLLAPSING; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index 50f81ff13825..e9ec3236a06c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -131,6 +131,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { private SelectedUserInteractor mSelectedUserInteractor; @Mock private BiometricUnlockInteractor mBiometricUnlockInteractor; + @Mock + private KeyguardTransitionInteractor mKeyguardTransitionInteractor; private final FakeSystemClock mSystemClock = new FakeSystemClock(); private BiometricUnlockController mBiometricUnlockController; @@ -167,7 +169,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { () -> mSelectedUserInteractor, mBiometricUnlockInteractor, mock(JavaAdapter.class), - mock(KeyguardTransitionInteractor.class) + mKeyguardTransitionInteractor ); biometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); biometricUnlockController.addListener(mBiometricUnlockEventsListener); @@ -374,6 +376,24 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { } @Test + public void onBiometricAuthenticated_whenFaceOnAlternateBouncer_dismissBouncer() { + when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true); + when(mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()).thenReturn(false); + when(mKeyguardTransitionInteractor.getCurrentState()) + .thenReturn(KeyguardState.ALTERNATE_BOUNCER); + // the value of isStrongBiometric doesn't matter here since we only care about the returned + // value of isUnlockingWithBiometricAllowed() + mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT, + BiometricSourceType.FACE, true /* isStrongBiometric */); + + verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(eq(false)); + assertThat(mBiometricUnlockController.getMode()) + .isEqualTo(BiometricUnlockController.MODE_DISMISS_BOUNCER); + assertThat(mBiometricUnlockController.getBiometricType()) + .isEqualTo(BiometricSourceType.FACE); + } + + @Test public void onBiometricAuthenticated_whenBypassOnBouncer_dismissBouncer() { reset(mKeyguardBypassController); when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true); |