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

Commit af657c90 authored by Beverly's avatar Beverly
Browse files

Don't use AOD device entry icon variant until dozing transition is finished

To avoid a race condition between the light reveal animation
finishing and the device entry icon using its aodVariant (desired
state for pulsing).

Test: atest DeviceEnryForegroundViewModelTest
Fixes: 338131603
Flag: com.android.systemui.device_entry_udfps_refactor
Flag: com.android.systemui.light_reveal_migration
Change-Id: I51f5353119493d2371e1d2cc0563c0ff1bfc6c32
parent aed28f85
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -58,6 +59,62 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() {
            assertThat(viewModel?.tint).isEqualTo(Color.WHITE)
        }

    @Test
    fun startsDozing_doNotShowAodVariant() =
        testScope.runTest {
            val viewModel by collectLastValue(underTest.viewModel)

            givenUdfpsEnrolledAndEnabled()
            kosmos.run {
                fakeKeyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.DOZING,
                    testScope = testScope,
                    throughTransitionState = TransitionState.STARTED,
                )
            }

            assertThat(viewModel?.useAodVariant).isEqualTo(false)
        }

    @Test
    fun finishedDozing_showAodVariant() =
        testScope.runTest {
            val viewModel by collectLastValue(underTest.viewModel)

            givenUdfpsEnrolledAndEnabled()
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.AOD,
                testScope = testScope,
                throughTransitionState = TransitionState.FINISHED,
            )

            assertThat(viewModel?.useAodVariant).isEqualTo(true)
        }

    @Test
    fun startTransitionToLockscreenFromDozing_doNotShowAodVariant() =
        testScope.runTest {
            val viewModel by collectLastValue(underTest.viewModel)

            givenUdfpsEnrolledAndEnabled()
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.DOZING,
                testScope = testScope,
                throughTransitionState = TransitionState.FINISHED,
            )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.DOZING,
                to = KeyguardState.LOCKSCREEN,
                testScope = testScope,
                throughTransitionState = TransitionState.RUNNING,
            )

            assertThat(viewModel?.useAodVariant).isEqualTo(false)
        }

    private fun givenUdfpsEnrolledAndEnabled() {
        kosmos.fakeFingerprintPropertyRepository.supportsUdfps()
        kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true)
+5 −2
Original line number Diff line number Diff line
@@ -52,8 +52,11 @@ constructor(
    udfpsOverlayInteractor: UdfpsOverlayInteractor,
) {
    private val isShowingAodOrDozing: Flow<Boolean> =
        transitionInteractor.startedKeyguardState.map { keyguardState ->
            keyguardState == KeyguardState.AOD || keyguardState == KeyguardState.DOZING
        combine(
            transitionInteractor.startedKeyguardState,
            transitionInteractor.transitionValue(KeyguardState.DOZING),
        ) { startedKeyguardState, dozingTransitionValue ->
            startedKeyguardState == KeyguardState.AOD || dozingTransitionValue == 1f
        }

    private fun getColor(usingBackgroundProtection: Boolean): Int {