From d421a8d868832ab2cb331ab1982a9b26f6126cbf Mon Sep 17 00:00:00 2001 From: Beverly Date: Fri, 14 May 2021 12:33:56 -0400 Subject: Don't update biometricListenState on SB stateChange On StatusBarState change, don't immediately update biometricListeningState or else it's possible we start face auth before the device turns off. We rely on other signals to update the biometricListeningState when all state (ie: dozing/sleeping) is properly set. This bug was introduced by ag/13020637 in a seemingly harmless small refactor of KeyguardUpdateMonitor's mStatusBarState handling. Test: atest KeyguardUpdateMonitorTest Test: manual Fixes: 187677463 Change-Id: I874273e1a5c9bd2d5e892702c4c154540cdc0a84 --- .../android/keyguard/KeyguardUpdateMonitor.java | 1 - .../keyguard/KeyguardUpdateMonitorTest.java | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 4523fee045f6..44df02a9023a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -252,7 +252,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab @Override public void onStateChanged(int newState) { mStatusBarState = newState; - updateBiometricListeningState(); } @Override diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index f779305b75ab..29b44051f92d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -942,6 +942,34 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(true)).isEqualTo(false); } + @Test + public void testShouldNotUpdateBiometricListeningStateOnStatusBarStateChange() { + // GIVEN state for face auth should run aside from StatusBarState + when(mDevicePolicyManager.getKeyguardDisabledFeatures(null, + KeyguardUpdateMonitor.getCurrentUser())).thenReturn(0); + mStatusBarStateListener.onStateChanged(StatusBarState.SHADE_LOCKED); + setKeyguardBouncerVisibility(false /* isVisible */); + mKeyguardUpdateMonitor.dispatchStartedWakingUp(); + when(mKeyguardBypassController.canBypass()).thenReturn(true); + mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + + // WHEN status bar state reports a change to the keyguard that would normally indicate to + // start running face auth + mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD); + assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isEqualTo(true); + + // THEN face unlock is not running b/c status bar state changes don't cause biometric + // listening state to update + assertThat(mKeyguardUpdateMonitor.isFaceUnlockRunning( + KeyguardUpdateMonitor.getCurrentUser())).isEqualTo(false); + + // WHEN biometric listening state is updated + mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + + // THEN face unlock is running + assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(true); + } + @Test public void testRequireUnlockForNfc_Broadcast() { KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class); -- cgit v1.2.3-59-g8ed1b