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

Commit 1be8f108 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Clear face auth locked out state after user switch." into main

parents a06518bf 0dae9817
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -107,7 +107,7 @@ interface DeviceEntryFaceAuthRepository {
    val isBypassEnabled: Flow<Boolean>
    val isBypassEnabled: Flow<Boolean>


    /** Set whether face authentication should be locked out or not */
    /** Set whether face authentication should be locked out or not */
    fun lockoutFaceAuth()
    fun setLockedOut(isLockedOut: Boolean)


    /**
    /**
     * Cancel current face authentication and prevent it from running until [resumeFaceAuth] is
     * Cancel current face authentication and prevent it from running until [resumeFaceAuth] is
@@ -228,8 +228,8 @@ constructor(
        }
        }
            ?: flowOf(false)
            ?: flowOf(false)


    override fun lockoutFaceAuth() {
    override fun setLockedOut(isLockedOut: Boolean) {
        _isLockedOut.value = true
        _isLockedOut.value = isLockedOut
    }
    }


    private val faceLockoutResetCallback =
    private val faceLockoutResetCallback =
+1 −1
Original line number Original line Diff line number Diff line
@@ -55,7 +55,7 @@ class NoopDeviceEntryFaceAuthRepository @Inject constructor() : DeviceEntryFaceA
    override val isBypassEnabled: Flow<Boolean>
    override val isBypassEnabled: Flow<Boolean>
        get() = emptyFlow()
        get() = emptyFlow()


    override fun lockoutFaceAuth() = Unit
    override fun setLockedOut(isLockedOut: Boolean) = Unit
    override fun pauseFaceAuth() = Unit
    override fun pauseFaceAuth() = Unit


    override fun resumeFaceAuth() = Unit
    override fun resumeFaceAuth() = Unit
+4 −4
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ constructor(
            .onEach {
            .onEach {
                if (it) {
                if (it) {
                    faceAuthenticationLogger.faceLockedOut("Fingerprint locked out")
                    faceAuthenticationLogger.faceLockedOut("Fingerprint locked out")
                    repository.lockoutFaceAuth()
                    repository.setLockedOut(true)
                }
                }
            }
            }
            .launchIn(applicationScope)
            .launchIn(applicationScope)
@@ -148,9 +148,9 @@ constructor(
                    repository.pauseFaceAuth()
                    repository.pauseFaceAuth()
                } else if (wasSwitching && !isSwitching) {
                } else if (wasSwitching && !isSwitching) {
                    val lockoutMode = facePropertyRepository.getLockoutMode(curr.userInfo.id)
                    val lockoutMode = facePropertyRepository.getLockoutMode(curr.userInfo.id)
                    if (lockoutMode == LockoutMode.PERMANENT || lockoutMode == LockoutMode.TIMED) {
                    repository.setLockedOut(
                        repository.lockoutFaceAuth()
                        lockoutMode == LockoutMode.PERMANENT || lockoutMode == LockoutMode.TIMED
                    }
                    )
                    repository.resumeFaceAuth()
                    repository.resumeFaceAuth()
                    yield()
                    yield()
                    runFaceAuth(
                    runFaceAuth(
+2 −2
Original line number Original line Diff line number Diff line
@@ -559,7 +559,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {


    @Test
    @Test
    fun authenticateDoesNotRunWhenFaceIsDisabled() =
    fun authenticateDoesNotRunWhenFaceIsDisabled() =
        testScope.runTest { testGatingCheckForFaceAuth { underTest.lockoutFaceAuth() } }
        testScope.runTest { testGatingCheckForFaceAuth { underTest.setLockedOut(true) } }


    @Test
    @Test
    fun authenticateDoesNotRunWhenUserIsCurrentlyTrusted() =
    fun authenticateDoesNotRunWhenUserIsCurrentlyTrusted() =
@@ -869,7 +869,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            initCollectors()
            initCollectors()
            assertThat(underTest.isLockedOut.value).isFalse()
            assertThat(underTest.isLockedOut.value).isFalse()


            underTest.lockoutFaceAuth()
            underTest.setLockedOut(true)
            runCurrent()
            runCurrent()


            assertThat(underTest.isLockedOut.value).isTrue()
            assertThat(underTest.isLockedOut.value).isTrue()
+8 −5
Original line number Original line Diff line number Diff line
@@ -244,15 +244,18 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
        testScope.runTest {
        testScope.runTest {
            underTest.start()
            underTest.start()


            // previously running
            // User switching has started
            fakeUserRepository.setSelectedUserInfo(primaryUser, SelectionStatus.SELECTION_COMPLETE)
            fakeUserRepository.setSelectedUserInfo(
            fakeUserRepository.setSelectedUserInfo(
                primaryUser,
                primaryUser,
                SelectionStatus.SELECTION_IN_PROGRESS
                SelectionStatus.SELECTION_IN_PROGRESS
            )
            )
            runCurrent()
            runCurrent()
            bouncerRepository.setPrimaryShow(true)
            assertThat(faceAuthRepository.isFaceAuthPaused()).isTrue()


            facePropertyRepository.setLockoutMode(secondaryUser.id, LockoutMode.TIMED)
            bouncerRepository.setPrimaryShow(true)
            // New user is not locked out.
            facePropertyRepository.setLockoutMode(secondaryUser.id, LockoutMode.NONE)
            fakeUserRepository.setSelectedUserInfo(
            fakeUserRepository.setSelectedUserInfo(
                secondaryUser,
                secondaryUser,
                SelectionStatus.SELECTION_COMPLETE
                SelectionStatus.SELECTION_COMPLETE
@@ -260,7 +263,7 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
            runCurrent()
            runCurrent()


            assertThat(faceAuthRepository.isFaceAuthPaused()).isFalse()
            assertThat(faceAuthRepository.isFaceAuthPaused()).isFalse()
            assertThat(faceAuthRepository.wasDisabled).isTrue()
            assertThat(faceAuthRepository.isLockedOut.value).isFalse()


            runCurrent()
            runCurrent()
            assertThat(faceAuthRepository.runningAuthRequest.value!!.first)
            assertThat(faceAuthRepository.runningAuthRequest.value!!.first)
@@ -406,7 +409,7 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
            fakeDeviceEntryFingerprintAuthRepository.setLockedOut(true)
            fakeDeviceEntryFingerprintAuthRepository.setLockedOut(true)
            runCurrent()
            runCurrent()


            assertThat(faceAuthRepository.wasDisabled).isTrue()
            assertThat(faceAuthRepository.isLockedOut.value).isTrue()
        }
        }


    companion object {
    companion object {
Loading