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

Commit 51bde555 authored by Grace Cheng's avatar Grace Cheng
Browse files

Prevent duplicate calls to show indicator

Add distinctUntilChanged check on showIndicatorForDeviceEntry to prevent duplicate calls to show the SFPS indicator

Flag: NONE
Fixes: 317610128
Test: atest DeviceEntrySideFpsOverlayInteractorTest
Test: (manual) try repro steps on b/317610128
Change-Id: I30728e366063feee02b8e6e6e8105848ad0d1aa6
parent d72883a3
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
@@ -86,6 +87,7 @@ constructor(
                showForAlternateBouncer ->
                showForPrimaryBouncer || showForAlternateBouncer
            }
            .distinctUntilChanged()

    private fun shouldShowIndicatorForPrimaryBouncer(): Boolean {
        val sfpsEnabled: Boolean =
+27 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.bouncer.ui.BouncerView
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor
import com.android.systemui.keyguard.DismissCallbackRegistry
import com.android.systemui.keyguard.data.repository.FakeBiometricSettingsRepository
@@ -69,6 +70,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {

    private val bouncerRepository = FakeKeyguardBouncerRepository()
    private val biometricSettingsRepository = FakeBiometricSettingsRepository()
    private val deviceEntryFingerprintAuthRepository = FakeDeviceEntryFingerprintAuthRepository()

    private lateinit var primaryBouncerInteractor: PrimaryBouncerInteractor
    private lateinit var alternateBouncerInteractor: AlternateBouncerInteractor
@@ -112,7 +114,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            DeviceEntrySideFpsOverlayInteractor(
                testScope.backgroundScope,
                mContext,
                FakeDeviceEntryFingerprintAuthRepository(),
                deviceEntryFingerprintAuthRepository,
                primaryBouncerInteractor,
                alternateBouncerInteractor,
                keyguardUpdateMonitor
@@ -216,6 +218,30 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            assertThat(showIndicatorForDeviceEntry).isEqualTo(false)
        }

    @Test
    fun ignoresDuplicateRequestsToShowIndicatorForDeviceEntry() =
        testScope.runTest {
            val showIndicatorForDeviceEntry by collectValues(underTest.showIndicatorForDeviceEntry)
            runCurrent()

            // Request to show indicator for primary bouncer showing
            updatePrimaryBouncer(
                isShowing = true,
                isAnimatingAway = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
            )

            // Another request to show indicator for deviceEntryFingerprintAuthRepository update
            deviceEntryFingerprintAuthRepository.setShouldUpdateIndicatorVisibility(true)

            // Request to show indicator for alternate bouncer showing
            bouncerRepository.setAlternateVisible(true)

            // Ensure only one show request is sent
            assertThat(showIndicatorForDeviceEntry).containsExactly(false, true)
        }

    private fun updatePrimaryBouncer(
        isShowing: Boolean,
        isAnimatingAway: Boolean,
+4 −0
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ class FakeDeviceEntryFingerprintAuthRepository @Inject constructor() :
    fun setAuthenticationStatus(status: FingerprintAuthenticationStatus) {
        _authenticationStatus.value = status
    }

    fun setShouldUpdateIndicatorVisibility(shouldUpdateIndicatorVisibility: Boolean) {
        _shouldUpdateIndicatorVisibility.value = shouldUpdateIndicatorVisibility
    }
}

@Module