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

Commit 7149fac7 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix isNotificationLaunchAnimationRunningOnKeyguard.

This flow was introduced in ag/26946263. When the keyguard_wm_state_refactor flag is enabled, it's used to determine whether the lockscreen is visible from a WM perspective.

Two issues weren't caught in the original CL review:
- We should be checking that isLaunchAnimationRunning=true as well as the finished state.
- We need to emit false onStart, or flows that combine this one won't emit until the next notification launch.

Bug: 278086361
Flag: ACONFIG com.android.systemui.keyguard_wm_state_refactor DEVELOPMENT
Test: manual
Change-Id: Idfe50983ff34b977b1e7ab84080f7a26ab016079
parent dc22ecf8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart

/**
 * Distance over which the surface behind the keyguard is animated in during a Y-translation
@@ -102,8 +103,11 @@ constructor(
     */
    private val isNotificationLaunchAnimationRunningOnKeyguard =
        notificationLaunchInteractor.isLaunchAnimationRunning
            .sample(transitionInteractor.finishedKeyguardState)
            .map { it != KeyguardState.GONE }
            .sample(transitionInteractor.finishedKeyguardState, ::Pair)
            .map { (animationRunning, finishedState) ->
                animationRunning && finishedState != KeyguardState.GONE
            }
            .onStart { emit(false) }

    /**
     * Whether we're animating the surface, or a notification launch animation is running (which
+23 −0
Original line number Diff line number Diff line
@@ -274,4 +274,27 @@ class KeyguardSurfaceBehindInteractorTest : SysuiTestCase() {
            runCurrent()
            assertThat(isAnimatingSurface).isFalse()
        }

    @Test
    fun notificationLaunchFalse_isAnimatingSurfaceFalse() =
        testScope.runTest {
            val isAnimatingSurface by collectLastValue(underTest.isAnimatingSurface)
            transitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.AOD,
                    to = KeyguardState.LOCKSCREEN,
                    transitionState = TransitionState.STARTED,
                )
            )
            transitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.AOD,
                    to = KeyguardState.LOCKSCREEN,
                    transitionState = TransitionState.FINISHED,
                )
            )
            kosmos.notificationLaunchAnimationInteractor.setIsLaunchAnimationRunning(false)
            runCurrent()
            assertThat(isAnimatingSurface).isFalse()
        }
}