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

Commit 86b4704e authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Update lockscreenVisibility when a transition is STARTED.

We miss the first STARTED transition otherwise, since the pairwise startedStepWithPrecedingStep hasn't emitted anything yet.

Bug: 278086361
Test: atest SystemUITests
Flag: com.android.systemui.keyguard_wm_state_refactor
Change-Id: Ic86470ca46296baddad4deba6f56574578850840
parent a931c067
Loading
Loading
Loading
Loading
+118 −1
Original line number Diff line number Diff line
@@ -771,6 +771,122 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @Test
    @DisableSceneContainer
    fun testLockscreenVisibility_trueDuringTransitionToGone_fromNotCanceledGone() =
        testScope.runTest {
            val values by collectValues(underTest.value.lockscreenVisibility)

            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope,
            )

            runCurrent()
            assertEquals(
                listOf(
                    true,
                    // Not visible when finished in GONE.
                    false,
                ),
                values,
            )

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.STARTED,
                    from = KeyguardState.GONE,
                    to = KeyguardState.LOCKSCREEN,
                )
            )
            runCurrent()
            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.RUNNING,
                    from = KeyguardState.GONE,
                    to = KeyguardState.LOCKSCREEN,
                )
            )
            runCurrent()

            assertEquals(
                listOf(
                    true,
                    // Still not visible during GONE -> LOCKSCREEN.
                    false,
                ),
                values,
            )

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.FINISHED,
                    from = KeyguardState.GONE,
                    to = KeyguardState.LOCKSCREEN,
                )
            )
            runCurrent()

            assertEquals(
                listOf(
                    true,
                    false,
                    // Visible now that we're FINISHED in LOCKSCREEN.
                    true,
                ),
                values,
            )

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.STARTED,
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                )
            )
            runCurrent()

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.RUNNING,
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                )
            )
            runCurrent()

            assertEquals(
                listOf(
                    true,
                    false,
                    // Remains true until the transition ends.
                    true,
                ),
                values,
            )

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.FINISHED,
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                )
            )

            runCurrent()
            assertEquals(
                listOf(
                    true,
                    false,
                    true,
                    // Until we're finished in GONE again.
                    false,
                ),
                values,
            )
        }

    @Test
    @DisableSceneContainer
    fun testLockscreenVisibility_falseDuringWakeAndUnlockToGone_fromNotCanceledGone() =
        testScope.runTest {
            val values by collectValues(underTest.value.lockscreenVisibility)

@@ -857,8 +973,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
                listOf(
                    true,
                    false,
                    // Remains visible from AOD during transition.
                    true,
                    // Becomes false immediately since we're wake and unlocking.
                    false,
                ),
                values,
            )
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ constructor(
        repository.transitions
            .pairwise()
            .filter { it.newValue.transitionState == TransitionState.STARTED }
            .shareIn(scope, SharingStarted.Eagerly)
            .shareIn(scope, SharingStarted.Eagerly, replay = 1)

    init {
        // Collect non-canceled steps and emit transition values.
+3 −4
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.notification.domain.interactor.NotificationLaunchAnimationInteractor
import com.android.systemui.util.kotlin.Utils.Companion.toQuad
import com.android.systemui.util.kotlin.sample
import com.android.systemui.utils.coroutines.flow.flatMapLatestConflated
import dagger.Lazy
import javax.inject.Inject
@@ -232,12 +231,12 @@ constructor(
    private val lockscreenVisibilityLegacy =
        combine(
                transitionInteractor.currentKeyguardState,
                transitionInteractor.startedStepWithPrecedingStep,
                wakeToGoneInteractor.canWakeDirectlyToGone,
                surfaceBehindVisibility,
                ::Triple,
                ::toQuad,
            )
            .sample(transitionInteractor.startedStepWithPrecedingStep, ::toQuad)
            .map { (currentState, canWakeDirectlyToGone, surfaceBehindVis, startedWithPrev) ->
            .map { (currentState, startedWithPrev, canWakeDirectlyToGone, surfaceBehindVis) ->
                val startedFromStep = startedWithPrev.previousValue
                val startedStep = startedWithPrev.newValue
                val returningToGoneAfterCancellation =