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

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

Merge "Prevent flickering during dream transition" into main

parents 0239aff3 995945ca
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -503,6 +503,45 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    @DisableSceneContainer
    fun alphaFromShadeExpansion_doesNotEmitWhenLockscreenToDreamTransitionRunning() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.LOCKSCREEN,
                testScope,
            )

            val alpha by collectLastValue(underTest.alpha(viewState))
            shadeTestUtil.setQsExpansion(0f)

            assertThat(alpha).isEqualTo(1f)

            keyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    TransitionStep(
                        from = KeyguardState.LOCKSCREEN,
                        to = KeyguardState.DREAMING,
                        transitionState = TransitionState.STARTED,
                        value = 0f,
                    ),
                    TransitionStep(
                        from = KeyguardState.LOCKSCREEN,
                        to = KeyguardState.DREAMING,
                        transitionState = TransitionState.RUNNING,
                        value = 0.1f,
                    ),
                ),
                testScope,
            )

            val alphaBeforeExpansion = alpha
            shadeTestUtil.setQsExpansion(0.5f)
            // Alpha should remain unchanged instead of being affected by expansion.
            assertThat(alpha).isEqualTo(alphaBeforeExpansion)
        }

    @Test
    fun alpha_shadeClosedOverLockscreen_isOne() =
        testScope.runTest {
+15 −19
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ constructor(

    private val alphaOnShadeExpansion: Flow<Float> =
        combineTransform(
                anyOf(
                    keyguardTransitionInteractor.isInTransition(
                        edge = Edge.create(from = LOCKSCREEN, to = Scenes.Gone),
                        edgeWithoutSceneContainer = Edge.create(from = LOCKSCREEN, to = GONE),
@@ -171,21 +172,16 @@ constructor(
                        edgeWithoutSceneContainer =
                            Edge.create(from = PRIMARY_BOUNCER, to = LOCKSCREEN),
                    ),
                    keyguardTransitionInteractor.isInTransition(
                        Edge.create(from = LOCKSCREEN, to = DREAMING)
                    ),
                ),
                isOnLockscreen,
                shadeInteractor.qsExpansion,
                shadeInteractor.shadeExpansion,
            ) {
                lockscreenToGoneTransitionRunning,
                primaryBouncerToLockscreenTransitionRunning,
                isOnLockscreen,
                qsExpansion,
                shadeExpansion ->
            ) { disabledTransitionRunning, isOnLockscreen, qsExpansion, shadeExpansion ->
                // Fade out quickly as the shade expands
                if (
                    isOnLockscreen &&
                        !lockscreenToGoneTransitionRunning &&
                        !primaryBouncerToLockscreenTransitionRunning
                ) {
                if (isOnLockscreen && !disabledTransitionRunning) {
                    val alpha =
                        1f -
                            MathUtils.constrainedMap(