diff options
3 files changed, 37 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractor.kt index ecf78d550a3f..b1a2297526ce 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractor.kt @@ -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 @@ -82,10 +83,11 @@ constructor( */ val showIndicatorForDeviceEntry: Flow<Boolean> = combine(showIndicatorForPrimaryBouncer, showIndicatorForAlternateBouncer) { - showForPrimaryBouncer, - showForAlternateBouncer -> - showForPrimaryBouncer || showForAlternateBouncer - } + showForPrimaryBouncer, + showForAlternateBouncer -> + showForPrimaryBouncer || showForAlternateBouncer + } + .distinctUntilChanged() private fun shouldShowIndicatorForPrimaryBouncer(): Boolean { val sfpsEnabled: Boolean = diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractorTest.kt index c4df27c2ccb2..cb8c40c333b3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/DeviceEntrySideFpsOverlayInteractorTest.kt @@ -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, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFingerprintAuthRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFingerprintAuthRepository.kt index 1d44929a20f0..93e0b418d076 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFingerprintAuthRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeDeviceEntryFingerprintAuthRepository.kt @@ -62,6 +62,10 @@ class FakeDeviceEntryFingerprintAuthRepository @Inject constructor() : fun setAuthenticationStatus(status: FingerprintAuthenticationStatus) { _authenticationStatus.value = status } + + fun setShouldUpdateIndicatorVisibility(shouldUpdateIndicatorVisibility: Boolean) { + _shouldUpdateIndicatorVisibility.value = shouldUpdateIndicatorVisibility + } } @Module |