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

Commit 70d4c462 authored by William Xiao's avatar William Xiao
Browse files

Fix notifications showing when starting dream with shade open

If the dream starts due to the user pressing power button or the screen
timing out when the shade is open on the lock screen, the shade
collapses but the notifications remain visible until the dream has
fully started.

This CL fixes the issue, which is caused by the notifications fading
back in on collapse. This CUJ is not often used so this bug has likely
been around for a long time.

Bug: 409720192
Test: atest SharedNotificationContainerViewModelTest
Flag: NONE small animation fix
Change-Id: If7bc0dd6336fbf6d5a954636b2f1b8048215167e
parent fb3b3339
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -1126,6 +1126,31 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            assertThat(fadeIn[0]).isEqualTo(false)
        }

    @Test
    fun shadeCollapseFadeIn_doesNotRunIfTransitioningToDream() =
        testScope.runTest {
            val fadeIn by collectValues(underTest.shadeCollapseFadeIn)

            // Start on lockscreen without the shade
            showLockscreen()
            assertThat(fadeIn[0]).isEqualTo(false)

            // ... then the shade expands
            showLockscreenWithShadeExpanded()
            assertThat(fadeIn[0]).isEqualTo(false)

            // ... then user hits power to go to dream
            keyguardTransitionRepository.sendTransitionSteps(
                from = LOCKSCREEN,
                to = DREAMING,
                testScope,
            )
            // ... followed by a shade collapse
            showLockscreen()
            // ... does not trigger a fade in
            assertThat(fadeIn[0]).isEqualTo(false)
        }

    @Test
    @BrokenWithSceneContainer(330311871)
    fun alpha_isZero_fromPrimaryBouncerToGoneWhileCommunalSceneVisible() =
+14 −6
Original line number Diff line number Diff line
@@ -412,8 +412,8 @@ constructor(
            .dumpValue("isDreamingWithoutShade")

    /**
     * Fade in if the user swipes the shade back up, not if collapsed by going to AOD. This is
     * needed due to the lack of a SHADE state with existing keyguard transitions.
     * Fade in if the user swipes the shade back up, not if collapsed by going to AOD or DREAMING.
     * This is needed due to the lack of a SHADE state with existing keyguard transitions.
     */
    private fun awaitCollapse(): Flow<Boolean> {
        var aodTransitionIsComplete = true
@@ -422,9 +422,13 @@ constructor(
                keyguardTransitionInteractor.isInTransition(
                    edge = Edge.create(from = LOCKSCREEN, to = AOD)
                ),
                ::Pair,
                keyguardTransitionInteractor.isInTransition(
                    edge = Edge.create(from = LOCKSCREEN, to = DREAMING)
                ),
                ::Triple,
            )
            .transformWhile { (isOnLockscreenWithoutShade, aodTransitionIsRunning) ->
            .transformWhile {
                (isOnLockscreenWithoutShade, aodTransitionIsRunning, dreamTransitionIsRunning) ->
                // Wait until the AOD transition is complete before terminating
                if (!aodTransitionIsComplete && !aodTransitionIsRunning) {
                    aodTransitionIsComplete = true
@@ -437,6 +441,9 @@ constructor(
                    // Shade is closed, fade in and terminate
                    emit(true)
                    false
                } else if (dreamTransitionIsRunning) {
                    emit(false)
                    false
                } else {
                    true
                }
@@ -452,8 +459,9 @@ constructor(
                    emit(false)
                    // Wait for shade to be fully expanded
                    isShadeLocked.first { it }
                    // ... and then for it to be collapsed OR a transition to AOD begins.
                    // If AOD, do not fade in (a fade out occurs instead).
                    // ... and then for it to be collapsed OR a transition to AOD or DREAMING
                    // begins.
                    // If AOD or DREAMING, do not fade in (a fade out occurs instead).
                    awaitCollapse().collect { doFadeIn ->
                        if (doFadeIn) {
                            emit(true)