diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 53229b9945a50..d950c917d8a37 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -2695,14 +2695,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab return mAuthController.isUdfpsSupported(); } - /** - * @return true if the FP sensor is non-UDFPS and the device can be unlocked using fingerprint - * at this moment. - */ - public boolean isFingerprintAllowedInBouncer() { - return !isUdfpsSupported() && isUnlockingWithFingerprintAllowed(); - } - /** * @return true if there's at least one sfps enrollment for the current user. */ diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactory.kt b/packages/SystemUI/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactory.kt index d767c47caeac2..1817ea9024fce 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactory.kt @@ -99,7 +99,7 @@ constructor( getBouncerMessage( reason, securityModel.getSecurityMode(userId), - updateMonitor.isFingerprintAllowedInBouncer + updateMonitor.isUnlockingWithFingerprintAllowed ) return pair?.let { BouncerMessageModel( @@ -115,43 +115,48 @@ constructor( /** * Helper method that provides the relevant bouncer message that should be shown for different - * scenarios indicated by [reason]. [securityMode] & [fpAllowedInBouncer] parameters are used to + * scenarios indicated by [reason]. [securityMode] & [fpAuthIsAllowed] parameters are used to * provide a more specific message. */ private fun getBouncerMessage( @BouncerPromptReason reason: Int, securityMode: SecurityMode, - fpAllowedInBouncer: Boolean = false + fpAuthIsAllowed: Boolean = false ): Pair? { return when (reason) { + // Primary auth locked out + PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT -> primaryAuthLockedOut(securityMode) + // Primary auth required reasons PROMPT_REASON_RESTART -> authRequiredAfterReboot(securityMode) PROMPT_REASON_TIMEOUT -> authRequiredAfterPrimaryAuthTimeout(securityMode) PROMPT_REASON_DEVICE_ADMIN -> authRequiredAfterAdminLockdown(securityMode) PROMPT_REASON_USER_REQUEST -> authRequiredAfterUserLockdown(securityMode) - PROMPT_REASON_AFTER_LOCKOUT -> biometricLockout(securityMode) PROMPT_REASON_PREPARE_FOR_UPDATE -> authRequiredForUnattendedUpdate(securityMode) PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE -> authRequiredForMainlineUpdate(securityMode) PROMPT_REASON_FINGERPRINT_LOCKED_OUT -> fingerprintUnlockUnavailable(securityMode) + PROMPT_REASON_AFTER_LOCKOUT -> biometricLockout(securityMode) + // Non strong auth not available reasons PROMPT_REASON_FACE_LOCKED_OUT -> - if (fpAllowedInBouncer) faceLockedOutButFingerprintAvailable(securityMode) + if (fpAuthIsAllowed) faceLockedOutButFingerprintAvailable(securityMode) else faceLockedOut(securityMode) - PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT -> - if (fpAllowedInBouncer) incorrectSecurityInputWithFingerprint(securityMode) - else incorrectSecurityInput(securityMode) PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT -> - if (fpAllowedInBouncer) nonStrongAuthTimeoutWithFingerprintAllowed(securityMode) + if (fpAuthIsAllowed) nonStrongAuthTimeoutWithFingerprintAllowed(securityMode) else nonStrongAuthTimeout(securityMode) PROMPT_REASON_TRUSTAGENT_EXPIRED -> - if (fpAllowedInBouncer) trustAgentDisabledWithFingerprintAllowed(securityMode) + if (fpAuthIsAllowed) trustAgentDisabledWithFingerprintAllowed(securityMode) else trustAgentDisabled(securityMode) + // Auth incorrect input reasons. + PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT -> + if (fpAuthIsAllowed) incorrectSecurityInputWithFingerprint(securityMode) + else incorrectSecurityInput(securityMode) PROMPT_REASON_INCORRECT_FACE_INPUT -> - if (fpAllowedInBouncer) incorrectFaceInputWithFingerprintAllowed(securityMode) + if (fpAuthIsAllowed) incorrectFaceInputWithFingerprintAllowed(securityMode) else incorrectFaceInput(securityMode) PROMPT_REASON_INCORRECT_FINGERPRINT_INPUT -> incorrectFingerprintInput(securityMode) + // Default message PROMPT_REASON_DEFAULT -> - if (fpAllowedInBouncer) defaultMessageWithFingerprint(securityMode) + if (fpAuthIsAllowed) defaultMessageWithFingerprint(securityMode) else defaultMessage(securityMode) - PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT -> primaryAuthLockedOut(securityMode) else -> null } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactoryTest.kt index 77dd9eeb261cc..efae3fe1af2c7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/factory/BouncerMessageFactoryTest.kt @@ -59,21 +59,21 @@ class BouncerMessageFactoryTest : SysuiTestCase() { } @Test - fun bouncerMessages_choosesTheRightMessage_basedOnSecurityModeAndFpAllowedInBouncer() = + fun bouncerMessages_choosesTheRightMessage_basedOnSecurityModeAndFpAuthIsAllowed() = testScope.runTest { - primaryMessage(PROMPT_REASON_DEFAULT, mode = PIN, fpAllowedInBouncer = false) + primaryMessage(PROMPT_REASON_DEFAULT, mode = PIN, fpAuthAllowed = false) .isEqualTo("Enter PIN") - primaryMessage(PROMPT_REASON_DEFAULT, mode = PIN, fpAllowedInBouncer = true) + primaryMessage(PROMPT_REASON_DEFAULT, mode = PIN, fpAuthAllowed = true) .isEqualTo("Unlock with PIN or fingerprint") - primaryMessage(PROMPT_REASON_DEFAULT, mode = Password, fpAllowedInBouncer = false) + primaryMessage(PROMPT_REASON_DEFAULT, mode = Password, fpAuthAllowed = false) .isEqualTo("Enter password") - primaryMessage(PROMPT_REASON_DEFAULT, mode = Password, fpAllowedInBouncer = true) + primaryMessage(PROMPT_REASON_DEFAULT, mode = Password, fpAuthAllowed = true) .isEqualTo("Unlock with password or fingerprint") - primaryMessage(PROMPT_REASON_DEFAULT, mode = Pattern, fpAllowedInBouncer = false) + primaryMessage(PROMPT_REASON_DEFAULT, mode = Pattern, fpAuthAllowed = false) .isEqualTo("Draw pattern") - primaryMessage(PROMPT_REASON_DEFAULT, mode = Pattern, fpAllowedInBouncer = true) + primaryMessage(PROMPT_REASON_DEFAULT, mode = Pattern, fpAuthAllowed = true) .isEqualTo("Unlock with pattern or fingerprint") } @@ -94,44 +94,44 @@ class BouncerMessageFactoryTest : SysuiTestCase() { } @Test - fun bouncerMessages_setsPrimaryAndSecondaryMessage_basedOnSecurityModeAndFpAllowedInBouncer() = + fun bouncerMessages_setsPrimaryAndSecondaryMessage_basedOnSecurityModeAndFpAuthIsAllowed() = testScope.runTest { primaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = PIN, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Wrong PIN. Try again.") secondaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = PIN, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Or unlock with fingerprint") primaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = Password, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Wrong password. Try again.") secondaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = Password, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Or unlock with fingerprint") primaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = Pattern, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Wrong pattern. Try again.") secondaryMessage( PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT, mode = Pattern, - fpAllowedInBouncer = true + fpAuthAllowed = true ) .isEqualTo("Or unlock with fingerprint") } @@ -139,11 +139,11 @@ class BouncerMessageFactoryTest : SysuiTestCase() { private fun primaryMessage( reason: Int, mode: KeyguardSecurityModel.SecurityMode, - fpAllowedInBouncer: Boolean + fpAuthAllowed: Boolean ): StringSubject { return assertThat( context.resources.getString( - bouncerMessageModel(mode, fpAllowedInBouncer, reason)!!.message!!.messageResId!! + bouncerMessageModel(mode, fpAuthAllowed, reason)!!.message!!.messageResId!! ) )!! } @@ -151,25 +151,23 @@ class BouncerMessageFactoryTest : SysuiTestCase() { private fun secondaryMessage( reason: Int, mode: KeyguardSecurityModel.SecurityMode, - fpAllowedInBouncer: Boolean + fpAuthAllowed: Boolean ): StringSubject { return assertThat( context.resources.getString( - bouncerMessageModel(mode, fpAllowedInBouncer, reason)!! - .secondaryMessage!! - .messageResId!! + bouncerMessageModel(mode, fpAuthAllowed, reason)!!.secondaryMessage!!.messageResId!! ) )!! } private fun bouncerMessageModel( mode: KeyguardSecurityModel.SecurityMode, - fpAllowedInBouncer: Boolean, + fpAuthAllowed: Boolean, reason: Int, secondaryMessageOverride: String? = null, ): BouncerMessageModel? { whenever(securityModel.getSecurityMode(0)).thenReturn(mode) - whenever(updateMonitor.isFingerprintAllowedInBouncer).thenReturn(fpAllowedInBouncer) + whenever(updateMonitor.isUnlockingWithFingerprintAllowed).thenReturn(fpAuthAllowed) return underTest.createFromPromptReason( reason, diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/repo/BouncerMessageRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/repo/BouncerMessageRepositoryTest.kt index e1b608b6f544a..2be7d8a43a189 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/repo/BouncerMessageRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/data/repo/BouncerMessageRepositoryTest.kt @@ -101,7 +101,7 @@ class BouncerMessageRepositoryTest : SysuiTestCase() { fingerprintRepository = FakeDeviceEntryFingerprintAuthRepository() testScope = TestScope() - whenever(updateMonitor.isFingerprintAllowedInBouncer).thenReturn(false) + whenever(updateMonitor.isUnlockingWithFingerprintAllowed).thenReturn(false) whenever(securityModel.getSecurityMode(PRIMARY_USER_ID)).thenReturn(PIN) underTest = BouncerMessageRepositoryImpl( diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerMessageInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerMessageInteractorTest.kt index 283c02f925e45..3ca94aa8e7afa 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerMessageInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerMessageInteractorTest.kt @@ -76,7 +76,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() { allowTestableLooperAsMainThread() whenever(securityModel.getSecurityMode(PRIMARY_USER_ID)).thenReturn(PIN) - whenever(updateMonitor.isFingerprintAllowedInBouncer).thenReturn(false) + whenever(updateMonitor.isUnlockingWithFingerprintAllowed).thenReturn(false) } suspend fun TestScope.init() {