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

Commit 57f30aa1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix issue where unlocked content is visible during shade collapse." into main

parents bd776711 dfc4e65f
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 ->