diff options
4 files changed, 15 insertions, 104 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt index b78fa9a6b392..71470e8870de 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt @@ -57,11 +57,10 @@ data class KeyguardFaceListenModel( val faceLockedOut: Boolean, val fpLockedOut: Boolean, val goingToSleep: Boolean, - val keyguardAwakeExcludingBouncerShowing: Boolean, + val keyguardAwake: Boolean, val keyguardGoingAway: Boolean, val listeningForFaceAssistant: Boolean, val occludingAppRequestingFaceAuth: Boolean, - val onlyFaceEnrolled: Boolean, val primaryUser: Boolean, val scanningAllowedByStrongAuth: Boolean, val secureCameraLaunched: Boolean, diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 4b6177a03585..f259a542908c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -2579,11 +2579,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED; - // mKeyguardIsVisible is true even when the bouncer is shown, we don't want to run face auth - // on bouncer if both fp and fingerprint are enrolled. - final boolean awakeKeyguardExcludingBouncerShowing = mKeyguardIsVisible - && mDeviceInteractive && !mGoingToSleep - && !statusBarShadeLocked && !mBouncerFullyShown; + final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep + && !statusBarShadeLocked; final int user = getCurrentUser(); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); final boolean isLockDown = @@ -2623,16 +2620,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab final boolean faceDisabledForUser = isFaceDisabled(user); final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user); final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant(); - final boolean onlyFaceEnrolled = isOnlyFaceEnrolled(); final boolean fpOrFaceIsLockedOut = isFaceLockedOut() || fpLockedout; // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. final boolean shouldListen = - ((mBouncerFullyShown && !mGoingToSleep && onlyFaceEnrolled) + (mBouncerFullyShown && !mGoingToSleep || mAuthInterruptActive || mOccludingAppRequestingFace - || awakeKeyguardExcludingBouncerShowing + || awakeKeyguard || shouldListenForFaceAssistant || mAuthController.isUdfpsFingerDown() || mUdfpsBouncerShowing) @@ -2658,11 +2654,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab isFaceLockedOut(), fpLockedout, mGoingToSleep, - awakeKeyguardExcludingBouncerShowing, + awakeKeyguard, mKeyguardGoingAway, shouldListenForFaceAssistant, mOccludingAppRequestingFace, - onlyFaceEnrolled, mIsPrimaryUser, strongAuthAllowsScanning, mSecureCameraLaunched, @@ -2672,11 +2667,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab return shouldListen; } - private boolean isOnlyFaceEnrolled() { - return isFaceEnrolled() - && !getCachedIsUnlockWithFingerprintPossible(sCurrentUser); - } - private void maybeLogListenerModelData(KeyguardListenModel model) { mLogger.logKeyguardListenerModel(model); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt index 485a7e5738f1..aca60c033bac 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt @@ -86,13 +86,12 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel( becauseCannotSkipBouncer = false, biometricSettingEnabledForUser = false, bouncerFullyShown = false, - onlyFaceEnrolled = false, faceAuthenticated = false, faceDisabled = false, faceLockedOut = false, fpLockedOut = false, goingToSleep = false, - keyguardAwakeExcludingBouncerShowing = false, + keyguardAwake = false, keyguardGoingAway = false, listeningForFaceAssistant = false, occludingAppRequestingFaceAuth = false, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index e7e3f34b1399..12d3d42cb29f 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -213,8 +213,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mBiometricEnabledCallbackArgCaptor; @Captor private ArgumentCaptor<FaceManager.AuthenticationCallback> mAuthenticationCallbackCaptor; - @Captor - private ArgumentCaptor<CancellationSignal> mCancellationSignalCaptor; // Direct executor private final Executor mBackgroundExecutor = Runnable::run; @@ -597,13 +595,11 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testTriesToAuthenticate_whenBouncer() { - fingerprintIsNotEnrolled(); - faceAuthEnabled(); setKeyguardBouncerVisibility(true); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); - verify(mFaceManager, atLeastOnce()).isHardwareDetected(); - verify(mFaceManager, atLeastOnce()).hasEnrolledTemplates(anyInt()); + verify(mFaceManager).isHardwareDetected(); + verify(mFaceManager).hasEnrolledTemplates(anyInt()); } @Test @@ -1238,9 +1234,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testShouldListenForFace_whenFaceIsAlreadyAuthenticated_returnsFalse() throws RemoteException { // Face auth should run when the following is true. - faceAuthEnabled(); bouncerFullyVisibleAndNotGoingToSleep(); - fingerprintIsNotEnrolled(); keyguardNotGoingAway(); currentUserIsPrimary(); strongAuthNotRequired(); @@ -1267,7 +1261,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext); - // Preconditions for face auth to run + // Face auth should run when the following is true. keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); strongAuthNotRequired(); @@ -1284,7 +1278,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenStrongAuthDoesNotAllowScanning_returnsFalse() throws RemoteException { - // Preconditions for face auth to run + // Face auth should run when the following is true. keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); currentUserIsPrimary(); @@ -1305,11 +1299,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenBiometricsDisabledForUser_returnsFalse() throws RemoteException { - // Preconditions for face auth to run - faceAuthEnabled(); keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); - fingerprintIsNotEnrolled(); currentUserIsPrimary(); currentUserDoesNotHaveTrust(); biometricsNotDisabledThroughDevicePolicyManager(); @@ -1329,11 +1320,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenUserCurrentlySwitching_returnsFalse() throws RemoteException { - // Preconditions for face auth to run - faceAuthEnabled(); + // Face auth should run when the following is true. keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); - fingerprintIsNotEnrolled(); currentUserIsPrimary(); currentUserDoesNotHaveTrust(); biometricsNotDisabledThroughDevicePolicyManager(); @@ -1352,11 +1341,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenSecureCameraLaunched_returnsFalse() throws RemoteException { - // Preconditions for face auth to run - faceAuthEnabled(); keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); - fingerprintIsNotEnrolled(); currentUserIsPrimary(); currentUserDoesNotHaveTrust(); biometricsNotDisabledThroughDevicePolicyManager(); @@ -1375,7 +1361,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenOccludingAppRequestsFaceAuth_returnsTrue() throws RemoteException { - // Preconditions for face auth to run + // Face auth should run when the following is true. keyguardNotGoingAway(); bouncerFullyVisibleAndNotGoingToSleep(); currentUserIsPrimary(); @@ -1398,8 +1384,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenBouncerShowingAndDeviceIsAwake_returnsTrue() throws RemoteException { - // Preconditions for face auth to run - faceAuthEnabled(); + // Face auth should run when the following is true. keyguardNotGoingAway(); currentUserIsPrimary(); currentUserDoesNotHaveTrust(); @@ -1411,7 +1396,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); bouncerFullyVisibleAndNotGoingToSleep(); - fingerprintIsNotEnrolled(); mTestableLooper.processAllMessages(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue(); @@ -1420,7 +1404,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { @Test public void testShouldListenForFace_whenAuthInterruptIsActive_returnsTrue() throws RemoteException { - // Preconditions for face auth to run + // Face auth should run when the following is true. keyguardNotGoingAway(); currentUserIsPrimary(); currentUserDoesNotHaveTrust(); @@ -1446,7 +1430,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { biometricsNotDisabledThroughDevicePolicyManager(); biometricsEnabledForCurrentUser(); userNotCurrentlySwitching(); - bouncerFullyVisible(); statusBarShadeIsLocked(); mTestableLooper.processAllMessages(); @@ -1460,9 +1443,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { keyguardIsVisible(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); statusBarShadeIsNotLocked(); - assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); - bouncerNotFullyVisible(); - assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue(); } @@ -1524,44 +1504,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } @Test - public void testBouncerVisibility_whenBothFingerprintAndFaceIsEnrolled_stopsFaceAuth() - throws RemoteException { - // Both fingerprint and face are enrolled by default - // Preconditions for face auth to run - keyguardNotGoingAway(); - currentUserIsPrimary(); - currentUserDoesNotHaveTrust(); - biometricsNotDisabledThroughDevicePolicyManager(); - biometricsEnabledForCurrentUser(); - userNotCurrentlySwitching(); - deviceNotGoingToSleep(); - deviceIsInteractive(); - statusBarShadeIsNotLocked(); - keyguardIsVisible(); - - mTestableLooper.processAllMessages(); - clearInvocations(mUiEventLogger); - - assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue(); - - mKeyguardUpdateMonitor.requestFaceAuth(true, - FaceAuthApiRequestReason.UDFPS_POINTER_DOWN); - - verify(mFaceManager).authenticate(any(), - mCancellationSignalCaptor.capture(), - mAuthenticationCallbackCaptor.capture(), - any(), - anyInt(), - anyBoolean()); - CancellationSignal cancelSignal = mCancellationSignalCaptor.getValue(); - - bouncerFullyVisible(); - mTestableLooper.processAllMessages(); - - assertThat(cancelSignal.isCanceled()).isTrue(); - } - - @Test public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); @@ -1624,21 +1566,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { .onAuthenticationError(FaceManager.FACE_ERROR_LOCKOUT_PERMANENT, ""); } - private void faceAuthEnabled() { - // this ensures KeyguardUpdateMonitor updates the cached mIsFaceEnrolled flag using the - // face manager mock wire-up in setup() - mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(mCurrentUserId); - } - - private void fingerprintIsNotEnrolled() { - when(mFingerprintManager.hasEnrolledTemplates(mCurrentUserId)).thenReturn(false); - // This updates the cached fingerprint state. - // There is no straightforward API to update the fingerprint state. - // It currently works updates after enrollment changes because something else invokes - // startListeningForFingerprint(), which internally calls this method. - mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible(mCurrentUserId); - } - private void statusBarShadeIsNotLocked() { mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD); } @@ -1745,10 +1672,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); } - private void bouncerNotFullyVisible() { - setKeyguardBouncerVisibility(false); - } - private void bouncerFullyVisible() { setKeyguardBouncerVisibility(true); } |