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

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

Merge "Don't use AOD device entry icon variant until dozing transition is finished" into main

parents 73b4d9a9 af657c90
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 {