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

Commit 12d35805 authored by Chandru S's avatar Chandru S
Browse files

Run face detection if bypass is enabled and the user is already trusted.

 - If the device is already unlocked using smart lock, we should run face detection to auto-dismiss the lock screen.

Fixes: 285526875
Test: DeviceEntryFaceAuthRepositoryTest
Change-Id: I3dc4eaf6fdf5668fa7c156832b9ab27ce87ef2fc
parent 15d98dc3
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -254,13 +254,17 @@ constructor(


    private fun observeFaceDetectGatingChecks() {
    private fun observeFaceDetectGatingChecks() {
        // Face detection can run only when lockscreen bypass is enabled
        // 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(
        listOf(
                canFaceAuthOrDetectRun(faceDetectLog),
                canFaceAuthOrDetectRun(faceDetectLog),
                logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog),
                logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog),
                logAndObserve(
                logAndObserve(
                    biometricSettingsRepository.isNonStrongBiometricAllowed.isFalse(),
                    biometricSettingsRepository.isNonStrongBiometricAllowed
                    "nonStrongBiometricIsNotAllowed",
                        .isFalse()
                        .or(trustRepository.isCurrentUserTrusted),
                    "nonStrongBiometricIsNotAllowedOrCurrentUserIsTrusted",
                    faceDetectLog
                    faceDetectLog
                ),
                ),
                // We don't want to run face detect if fingerprint can be used to unlock the device
                // We don't want to run face detect if fingerprint can be used to unlock the device
+21 −0
Original line number Original line Diff line number Diff line
@@ -625,6 +625,27 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            faceDetectIsCalled()
            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
    @Test
    fun everythingWorksWithFaceAuthRefactorFlagDisabled() =
    fun everythingWorksWithFaceAuthRefactorFlagDisabled() =
        testScope.runTest {
        testScope.runTest {