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

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

Merge "Fix UDFPS flicker on LOCKSCREEN->DOZING" into main

parents 7c738dee c0bb65e5
Loading
Loading
Loading
Loading
+25 −31
Original line number Diff line number Diff line
@@ -57,9 +57,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                    duration = 1000.milliseconds,
                    edge = Edge.create(from = Scenes.Gone, to = DREAMING),
                )
                .setupWithoutSceneContainer(
                    edge = Edge.create(from = GONE, to = DREAMING),
                )
                .setupWithoutSceneContainer(edge = Edge.create(from = GONE, to = DREAMING))
    }

    @Test(expected = IllegalArgumentException::class)
@@ -75,7 +73,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                underTest.sharedFlow(
                    startTime = 300.milliseconds,
                    duration = 800.milliseconds,
                    onStep = { it }
                    onStep = { it },
                )
        }

@@ -111,6 +109,17 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
            assertThat(animationValues()).isEqualTo(100f)
        }

    @Test
    fun onStepReturnsNullEmitsNothing() =
        testScope.runTest {
            val flow = underTest.sharedFlow(duration = 100.milliseconds, onStep = { null })
            var animationValues = collectLastValue(flow)
            runCurrent()

            repository.sendTransitionStep(step(0.5f, TransitionState.RUNNING))
            assertThat(animationValues()).isNull()
        }

    @Test
    fun usesStartTime() =
        testScope.runTest {
@@ -166,11 +175,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    @Test
    fun usesOnStepToDoubleValue() =
        testScope.runTest {
            val flow =
                underTest.sharedFlow(
                    duration = 1000.milliseconds,
                    onStep = { it * 2 },
                )
            val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it * 2 })
            val animationValues by collectLastValue(flow)
            runCurrent()

@@ -190,10 +195,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    fun usesOnStepToDoubleValueWithState() =
        testScope.runTest {
            val flow =
                underTest.sharedFlowWithState(
                    duration = 1000.milliseconds,
                    onStep = { it * 2 },
                )
                underTest.sharedFlowWithState(duration = 1000.milliseconds, onStep = { it * 2 })
            val animationValues by collectLastValue(flow)
            runCurrent()

@@ -204,7 +206,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.STARTED,
                        value = 0f
                        value = 0f,
                    )
                )
            repository.sendTransitionStep(step(0.3f, TransitionState.RUNNING))
@@ -214,7 +216,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.RUNNING,
                        value = 0.6f
                        value = 0.6f,
                    )
                )
            repository.sendTransitionStep(step(0.6f, TransitionState.RUNNING))
@@ -224,7 +226,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.RUNNING,
                        value = 1.2f
                        value = 1.2f,
                    )
                )
            repository.sendTransitionStep(step(0.8f, TransitionState.RUNNING))
@@ -234,7 +236,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.RUNNING,
                        value = 1.6f
                        value = 1.6f,
                    )
                )
            repository.sendTransitionStep(step(1f, TransitionState.RUNNING))
@@ -244,7 +246,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.RUNNING,
                        value = 2f
                        value = 2f,
                    )
                )
            repository.sendTransitionStep(step(1f, TransitionState.FINISHED))
@@ -254,7 +256,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
                        from = GONE,
                        to = DREAMING,
                        transitionState = TransitionState.FINISHED,
                        value = null
                        value = null,
                    )
                )
        }
@@ -262,11 +264,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    @Test
    fun sameFloatValueWithTheSameTransitionStateDoesNotEmitTwice() =
        testScope.runTest {
            val flow =
                underTest.sharedFlow(
                    duration = 1000.milliseconds,
                    onStep = { it },
                )
            val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it })
            val values by collectValues(flow)
            runCurrent()

@@ -280,11 +278,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    @Test
    fun sameFloatValueWithADifferentTransitionStateDoesEmitTwice() =
        testScope.runTest {
            val flow =
                underTest.sharedFlow(
                    duration = 1000.milliseconds,
                    onStep = { it },
                )
            val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it })
            val values by collectValues(flow)
            runCurrent()

@@ -302,14 +296,14 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return TransitionStep(
            from = GONE,
            to = DREAMING,
            value = value,
            transitionState = state,
            ownerName = "GoneToDreamingTransitionViewModelTest"
            ownerName = "GoneToDreamingTransitionViewModelTest",
        )
    }
}
+10 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.coroutines.collectLastValue
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.keyguard.shared.model.TransitionState.FINISHED
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.shared.model.TransitionStep
@@ -63,7 +64,15 @@ class DeviceEntryBackgroundViewModelTest : SysuiTestCase() {
            )
            runCurrent()

            assertThat(alpha).isEqualTo(0.0f)
            assertThat(alpha).isEqualTo(1.0f)

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(lockscreenToDozing(1f, FINISHED)),
                testScope,
            )
            runCurrent()

            assertThat(alpha).isEqualTo(0f)
        }

    private fun lockscreenToDozing(value: Float, state: TransitionState = RUNNING): TransitionStep {
+5 −2
Original line number Diff line number Diff line
@@ -66,11 +66,14 @@ constructor(
         * range. This function maps the [startTime] and [duration] into [0, 1], when this subset is
         * valid.
         *
         * Note that [onStep] accepts a null return value. When null, no animation information will
         * be emitted, effectively saying "do not change the value on this frame"
         *
         * Note that [onCancel] isn't used when the scene framework is enabled.
         */
        fun sharedFlow(
            duration: Duration = transitionDuration,
            onStep: (Float) -> Float,
            onStep: (Float) -> Float?,
            startTime: Duration = 0.milliseconds,
            onStart: (() -> Unit)? = null,
            onCancel: (() -> Float)? = null,
@@ -102,7 +105,7 @@ constructor(
         */
        fun sharedFlowWithState(
            duration: Duration,
            onStep: (Float) -> Float,
            onStep: (Float) -> Float?,
            startTime: Duration = 0.milliseconds,
            onStart: (() -> Unit)? = null,
            onCancel: (() -> Float)? = null,
+6 −1
Original line number Diff line number Diff line
@@ -54,7 +54,12 @@ constructor(
        )

    val deviceEntryBackgroundViewAlpha: Flow<Float> =
        transitionAnimation.immediatelyTransitionTo(0f)
        transitionAnimation.sharedFlow(
            duration = TO_DOZING_DURATION,
            onStep = { null },
            onFinish = { 0f },
            onCancel = { 0f },
        )

    override val deviceEntryParentViewAlpha: Flow<Float> =
        deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest {