diff options
| author | 2024-04-09 20:56:49 +0000 | |
|---|---|---|
| committer | 2024-04-09 20:56:49 +0000 | |
| commit | f0a6b8bbf99cf283c0510e18e8d240691e475f71 (patch) | |
| tree | 04f3c406d8e74d5ff5a170adf59567cac8651ec8 | |
| parent | 19b955eb5651da67713ab96312a1e040588f62aa (diff) | |
| parent | 32bc4d8a5f15f2609fe4a4bda7b5e470826ca366 (diff) | |
Merge "Update fingerprint listening state after faceAuth cb is sent" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 9 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java | 29 |
2 files changed, 34 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 8c51a4e0ce66..4987724ea7b2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -225,7 +225,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab protected static final int BIOMETRIC_STATE_STOPPED = 0; /** Biometric authentication state: Listening. */ - private static final int BIOMETRIC_STATE_RUNNING = 1; + protected static final int BIOMETRIC_STATE_RUNNING = 1; /** * Biometric authentication: Cancelling and waiting for the relevant biometric service to @@ -1145,7 +1145,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab if (getUserCanSkipBouncer(userId)) { mTrustManager.unlockedByBiometricForUser(userId, FACE); } - updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE); mLogger.d("onFaceAuthenticated"); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); @@ -1156,6 +1155,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } + // Intentionally update the fingerprint running state after sending the + // onBiometricAuthenticated callback to listeners. Updating the fingerprint listening state + // can update the state of the device which listeners to the callback may rely on. + // For example, the alternate bouncer visibility state or udfps finger down state. + updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE); + // Only authenticate face once when assistant is visible mAssistantVisible = false; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index fde45d34a4fd..5af0c1f9765d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -52,6 +52,7 @@ import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; @@ -157,7 +158,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InOrder; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.MockitoSession; import org.mockito.internal.util.reflection.FieldSetter; @@ -809,6 +809,31 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } @Test + public void whenFaceAuthenticated_biometricAuthenticatedCallback_beforeUpdatingFpState() { + // GIVEN listening for UDFPS fingerprint + when(mAuthController.isUdfpsSupported()).thenReturn(true); + mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON); + mTestableLooper.processAllMessages(); + keyguardIsVisible(); + final CancellationSignal fpCancel = spy(mKeyguardUpdateMonitor.mFingerprintCancelSignal); + mKeyguardUpdateMonitor.mFingerprintCancelSignal = fpCancel; + + // WHEN face is authenticated + when(mFaceAuthInteractor.isAuthenticated()).thenReturn(true); + when(mFaceAuthInteractor.isFaceAuthStrong()).thenReturn(true); + when(mFaceAuthInteractor.isLockedOut()).thenReturn(false); + mKeyguardUpdateMonitor.onFaceAuthenticated(0, true); + mTestableLooper.processAllMessages(); + + // THEN verify keyguardUpdateMonitorCallback receives an onAuthenticated callback + // before cancelling the fingerprint request + InOrder inOrder = inOrder(mTestCallback, fpCancel); + inOrder.verify(mTestCallback).onBiometricAuthenticated( + eq(0), eq(BiometricSourceType.FACE), eq(true)); + inOrder.verify(fpCancel).cancel(); + } + + @Test public void whenDetectFingerprint_biometricDetectCallback() { ArgumentCaptor<FingerprintManager.FingerprintDetectionCallback> fpDetectCallbackCaptor = ArgumentCaptor.forClass(FingerprintManager.FingerprintDetectionCallback.class); @@ -2133,7 +2158,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { null /* trustGrantedMessages */); // THEN onTrustChanged is called FIRST - final InOrder inOrder = Mockito.inOrder(callback); + final InOrder inOrder = inOrder(callback); inOrder.verify(callback).onTrustChanged(eq(mSelectedUserInteractor.getSelectedUserId())); // AND THEN onTrustGrantedForCurrentUser callback called |