Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e2f72f5 authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Run face detection if bypass is enabled and the user is already trusted. am: 12d35805

parents d3443820 12d35805
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -254,13 +254,17 @@ constructor(

    private fun observeFaceDetectGatingChecks() {
        // Face detection can run only when lockscreen bypass is enabled
        // & detection is supported & biometric unlock is not allowed.
        // & detection is supported
        //   & biometric unlock is not allowed
        //     or user is trusted by trust manager & we want to run face detect to dismiss keyguard
        listOf(
                canFaceAuthOrDetectRun(faceDetectLog),
                logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog),
                logAndObserve(
                    biometricSettingsRepository.isNonStrongBiometricAllowed.isFalse(),
                    "nonStrongBiometricIsNotAllowed",
                    biometricSettingsRepository.isNonStrongBiometricAllowed
                        .isFalse()
                        .or(trustRepository.isCurrentUserTrusted),
                    "nonStrongBiometricIsNotAllowedOrCurrentUserIsTrusted",
                    faceDetectLog
                ),
                // We don't want to run face detect if fingerprint can be used to unlock the device
+21 −0
Original line number Diff line number Diff line
@@ -625,6 +625,27 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            faceDetectIsCalled()
        }

    @Test
    fun authenticateFallbacksToDetectionWhenUserIsAlreadyTrustedByTrustManager() =
        testScope.runTest {
            whenever(faceManager.sensorPropertiesInternal)
                .thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = true)))
            whenever(bypassController.bypassEnabled).thenReturn(true)
            underTest = createDeviceEntryFaceAuthRepositoryImpl()
            initCollectors()
            allPreconditionsToRunFaceAuthAreTrue()

            trustRepository.setCurrentUserTrusted(true)
            assertThat(canFaceAuthRun()).isFalse()
            underTest.authenticate(
                FACE_AUTH_TRIGGERED_SWIPE_UP_ON_BOUNCER,
                fallbackToDetection = true
            )
            faceAuthenticateIsNotCalled()

            faceDetectIsCalled()
        }

    @Test
    fun everythingWorksWithFaceAuthRefactorFlagDisabled() =
        testScope.runTest {