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

Commit 41ca1697 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update PromptSelectorInteractor resetPrompt" into main

parents 99cabe3e fcd419ee
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