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

Commit 995945ca authored by Lucas Silva's avatar Lucas Silva
Browse files

Prevent flickering during dream transition

The shade expansion changes during the dream transition from 0->1 due to
status bar state changing. This causes the keyguard root alpha to be set
to 1 temporarily during the transition. Prevent this by ignoring shade
expansion changes while transitioning to the dream.

Bug: 361796575
Test: atest KeyguardRootViewModelTest
Flag: EXEMPT bugfix
Change-Id: I82f30df731698295ffea5f65c9fa3c285042f251
parent 64779bc9
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(