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

Commit dfc4e65f authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix issue where unlocked content is visible during shade collapse.

Fixed by simplifying the default LS vis to be false during transition if the device is entered and true if not.

Test: atest WindowManagerLockscreenVisibilityTest
Flag: com.android.systemui.scene_container
Fixes: 438154553
Change-Id: I1265d4106208b0dcd213cd531a70b50054bc19c3
parent ce4c4532
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
@@ -1228,6 +1228,83 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            assertEquals(listOf(false, true, false), aodVisibility)
        }

    @Test
    @EnableSceneContainer
    fun lockscreenVisibility_notVisibleCollapsingShadeOverLockscreen() =
        kosmos.runTest {
            enableSingleShade()
            runCurrent()

            setSceneTransition(Idle(Scenes.Lockscreen))

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Shade))
            sceneInteractor.changeScene(Scenes.Shade, "")
            assertThat(lockscreenVisibility).isTrue()

            // Ensure that LS remains not visible during Shade -> Lockscreen. Since Shade is not
            // explicitly a Keyguard scene, we've had regressions where lockscreen becomes visible
            // during transitions from Shade.
            setSceneTransition(Transition(from = Scenes.Shade, to = Scenes.Lockscreen))
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Lockscreen))
            sceneInteractor.changeScene(Scenes.Lockscreen, "")
            assertThat(lockscreenVisibility).isTrue()

            kosmos.authenticationInteractor.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)
            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")
            assertThat(lockscreenVisibility).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun lockscreenVisibility_remainsVisibleDuringLsGone() =
        kosmos.runTest {
            enableSingleShade()
            runCurrent()

            setSceneTransition(Idle(Scenes.Lockscreen))

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            assertThat(lockscreenVisibility).isTrue()

            kosmos.authenticationInteractor.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)
            setSceneTransition(Transition(from = Scenes.Lockscreen, to = Scenes.Gone))
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")
            assertThat(lockscreenVisibility).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun lockscreenVisibility_remainsNotVisibleDuringGoneLs() =
        kosmos.runTest {
            enableSingleShade()
            runCurrent()

            kosmos.authenticationInteractor.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)
            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            assertThat(lockscreenVisibility).isFalse()

            // Lockscreen vis remains false during Gone -> LS so the unlocked app content is visible
            // during the screen off animation.
            setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen))
            assertThat(lockscreenVisibility).isFalse()

            setSceneTransition(Idle(Scenes.Lockscreen))
            sceneInteractor.changeScene(Scenes.Lockscreen, "")
            assertThat(lockscreenVisibility).isTrue()
        }

    companion object {
        private val progress = MutableStateFlow(0f)

+11 −8
Original line number Diff line number Diff line
@@ -232,14 +232,17 @@ constructor(
                                        // visible.
                                        it.currentOverlays.contains(Overlays.Bouncer) ->
                                            flowOf(true)
                                        // If transitioning between two shade scenes and the bouncer
                                        // overlay is not showing, report that the keyguard is
                                        // visible if the device hasn't yet been entered.
                                        it.fromScene in shadeScenes && it.toScene in shadeScenes ->
                                            isDeviceNotEnteredDirectly
                                        // In all other cases, report that the keyguard isn't
                                        // visible.
                                        else -> flowOf(false)
                                        // Otherwise, default to showing the lockscreen if the
                                        // device is not yet entered, or leaving it not showing if
                                        // the device was entered. This covers two requirements:
                                        // - For LS -> Gone and vice versa, lockscreen visibility
                                        //   state needs to not change until the end of the
                                        //   transition, so that animations can play on the LS UI
                                        //   elements (or over the unlocked app content).
                                        // - For transitions such as Shade -> LS, which can occur
                                        //   both while locked and unlocked, the lockscreen
                                        //   visibility should simply not change.
                                        else -> isDeviceNotEnteredDirectly
                                    }

                                is Transition.OverlayTransition ->