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

Commit fcd419ee authored by Austin Delgado's avatar Austin Delgado
Browse files

Update PromptSelectorInteractor resetPrompt

Don't reset the current view if the resetPrompt call is for an invalid
requestId.

Bug: 431279910
Test: BiometricSimpleTests
Flag: EXEMPT bugfix
Change-Id: Ia539344274a9a029936a9d071321a78ddcc18d25
parent 3dc7bbbc
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -469,6 +469,28 @@ class PromptSelectorInteractorImplTest : SysuiTestCase() {
            verifyUnset()
        }

    @Test
    fun resetPrompt_onlyResetsViewForCurrentRequestId() =
        testScope.runTest {
            setUserCredentialType(isPassword = true)
            val currentView by collectLastValue(interactor.currentView)
            val requestId by collectLastValue(promptRepository.requestId)

            setPrompt(onSwitchToCredential = true)
            assertThat(currentView).isEqualTo(BiometricPromptView.CREDENTIAL)
            assertThat(requestId).isEqualTo(REQUEST_ID)

            interactor.resetPrompt(0L)

            assertThat(currentView).isEqualTo(BiometricPromptView.CREDENTIAL)
            assertThat(requestId).isEqualTo(REQUEST_ID)

            interactor.resetPrompt(REQUEST_ID)

            assertThat(currentView).isEqualTo(BiometricPromptView.BIOMETRIC)
            verifyUnset()
        }

    private fun setPrompt(
        info: PromptInfo = basicPromptInfo(),
        onSwitchToCredential: Boolean = false,
+4 −1
Original line number Diff line number Diff line
@@ -405,7 +405,10 @@ constructor(
    }

    override fun resetPrompt(requestId: Long) {
        val currentRequestId = promptRepository.requestId.value
        if (currentRequestId != null && currentRequestId == requestId) {
            _currentView.value = BiometricPromptView.BIOMETRIC
        }
        promptRepository.unsetPrompt(requestId)
    }

+10 −8
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ class FakePromptRepository : PromptRepository {
    }

    override fun unsetPrompt(requestId: Long) {
        if (requestId == _requestId.value) {
            _promptInfo.value = null
            _userId.value = null
            _modalities.value = BiometricModalities()
@@ -91,6 +92,7 @@ class FakePromptRepository : PromptRepository {
            _opPackageName.value = null
            _isConfirmationRequired.value = false
        }
    }

    fun setIsShowing(showing: Boolean) {
        _isShowing.value = showing