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

Commit 94d547df authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Fix notifications showing when starting dream with shade open" into main

parents 9c4fa2cd 70d4c462
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)