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

Commit fca11eff authored by Chandru S's avatar Chandru S
Browse files

Fix lockout not happening when auto confirm is enabled.

This was a bug introduced in the last clean up we did of this method.

Fixes: 332780986
Test: atest AuthenticationInteractorTest
Test: manually, set 6 digit PIN, attempt incorrect pin 5 times, notice the 30 second lockout
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I0b1b7285c523a55e30282f7659d38d2b0734aafa
parent 962de8cc
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -179,10 +179,14 @@ class AuthenticationInteractorTest : SysuiTestCase() {
                setAutoConfirmFeatureEnabled(true)
            }
            assertThat(isAutoConfirmEnabled).isTrue()
            val shorterPin =
                FakeAuthenticationRepository.DEFAULT_PIN.toMutableList().apply { removeLast() }
            val defaultPin = FakeAuthenticationRepository.DEFAULT_PIN.toMutableList()

            assertSkipped(underTest.authenticate(shorterPin, tryAutoConfirm = true))
            assertSkipped(
                underTest.authenticate(
                    defaultPin.subList(0, defaultPin.size - 1),
                    tryAutoConfirm = true
                )
            )
            assertThat(underTest.lockoutEndTimestamp).isNull()
            assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(0)
        }
@@ -201,7 +205,6 @@ class AuthenticationInteractorTest : SysuiTestCase() {

            assertFailed(
                underTest.authenticate(wrongPin, tryAutoConfirm = true),
                assertNoResultEvents = true,
            )
        }

@@ -219,7 +222,6 @@ class AuthenticationInteractorTest : SysuiTestCase() {

            assertFailed(
                underTest.authenticate(longerPin, tryAutoConfirm = true),
                assertNoResultEvents = true,
            )
        }

@@ -547,15 +549,10 @@ class AuthenticationInteractorTest : SysuiTestCase() {

    private fun assertFailed(
        authenticationResult: AuthenticationResult,
        assertNoResultEvents: Boolean = false,
    ) {
        assertThat(authenticationResult).isEqualTo(AuthenticationResult.FAILED)
        if (assertNoResultEvents) {
            assertThat(onAuthenticationResult).isNull()
        } else {
        assertThat(onAuthenticationResult).isFalse()
    }
    }

    private fun assertSkipped(
        authenticationResult: AuthenticationResult,
+0 −6
Original line number Diff line number Diff line
@@ -243,12 +243,6 @@ constructor(
        }

        // Authentication failed.

        if (tryAutoConfirm) {
            // Auto-confirm is active, the failed attempt should have no side-effects.
            return AuthenticationResult.FAILED
        }

        repository.reportAuthenticationAttempt(isSuccessful = false)

        if (authenticationResult.lockoutDurationMs > 0) {