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

Commit 962de8cc authored by Chandru S's avatar Chandru S
Browse files

Fix stale isAutoConfirmEnabled setting state.

 - confirmButtonAppearance is eagerly collected which in turn eagerly collects isAutoConfirmEnabled
 - isAutoConfirmEnabled refreshes its state in the repository whenever a new subscriber is added, but that doesn't happen because the flow is always hot.

Fixes: 332744173
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Bug: 332768183
Test: manually.
  1. change auto confirm setting under PIN bouncer setting
  2. check this is reflected in the bouncer.
Change-Id: I32d3b9af8e6df2b042f351508c3eae8da8d9dd64
parent 564df5d4
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -252,7 +252,14 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAutoConfirm_whenCorrect() =
        testScope.runTest {
            // TODO(b/332768183) remove this after the bug if fixed.
            // Collect the flow so that it is hot, in the real application this is done by using a
            // refreshingFlow that relies on the UI to make this flow hot.
            val autoConfirmEnabled by
                collectLastValue(authenticationInteractor.isAutoConfirmEnabled)
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(autoConfirmEnabled).isTrue()
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPinBouncer()

@@ -264,9 +271,17 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAutoConfirm_whenWrong() =
        testScope.runTest {
            // TODO(b/332768183) remove this after the bug if fixed.
            // Collect the flow so that it is hot, in the real application this is done by using a
            // refreshingFlow that relies on the UI to make this flow hot.
            val autoConfirmEnabled by
                collectLastValue(authenticationInteractor.isAutoConfirmEnabled)

            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(autoConfirmEnabled).isTrue()
            lockDeviceAndOpenPinBouncer()

            FakeAuthenticationRepository.DEFAULT_PIN.dropLast(1).forEach { digit ->
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class PinBouncerViewModel(
            .map { if (it) ActionButtonAppearance.Hidden else ActionButtonAppearance.Shown }
            .stateIn(
                scope = viewModelScope,
                started = SharingStarted.Eagerly,
                started = SharingStarted.WhileSubscribed(),
                initialValue = ActionButtonAppearance.Hidden,
            )