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

Commit 3061256e authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Dismissible lockscreen shows when folded.

On foldables, if "Continue using apps on fold" is set to "Swipe up to continue", the dismissible lockscreen should show when the unlocked/entered device is folded. This isn't working.

By removing handleSurfaceBehindKeyguardVisibility, we eliminate the
logic that was returning to the Gone scene from the Lockscreen scene
when the surface behind was made visible.

In addition, the change in WindowManagerLockscreenVisibilityInteractor
was also necessary to make sure that the surface behind doesn't become
visible prematurely.

Fix: 376693347
Test: manually verified behaviour when folding using all three settings
of "Continue using apps on fold"
Flag: com.android.systemui.scene_container

Change-Id: I8f23efa6128b9e7c58d6b994e5295be31edbfbf6
parent 74ba0bfe
Loading
Loading
Loading
Loading
+5 −42
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_fromLockscreenToGone_noUserInput_trueThroughout() =
    fun surfaceBehindVisibility_fromLockscreenToGone_dependsOnDeviceEntry() =
        testScope.runTest {
            val isSurfaceBehindVisible by collectLastValue(underTest.value.surfaceBehindVisibility)
            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)
@@ -208,7 +208,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
                SuccessFingerprintAuthenticationStatus(0, true)
            )

            // Start the transition to Gone, the surface should become immediately visible.
            // Start the transition to Gone, the surface should remain invisible.
            kosmos.setSceneTransition(
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Lockscreen,
@@ -220,9 +220,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
                )
            )
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(isSurfaceBehindVisible).isTrue()
            assertThat(isSurfaceBehindVisible).isFalse()

            // Towards the end of the transition, the surface should continue to be visible.
            // Towards the end of the transition, the surface should continue to remain invisible.
            kosmos.setSceneTransition(
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Lockscreen,
@@ -234,7 +234,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
                )
            )
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(isSurfaceBehindVisible).isTrue()
            assertThat(isSurfaceBehindVisible).isFalse()

            // After the transition, settles on Gone. Surface behind should stay visible now.
            kosmos.setSceneTransition(ObservableTransitionState.Idle(Scenes.Gone))
@@ -243,43 +243,6 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            assertThat(isSurfaceBehindVisible).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_fromLockscreenToGone_withUserInput_falseUntilInputStops() =
        testScope.runTest {
            val isSurfaceBehindVisible by collectLastValue(underTest.value.surfaceBehindVisibility)
            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)

            // Before the transition, we start on Lockscreen so the surface should start invisible.
            kosmos.setSceneTransition(ObservableTransitionState.Idle(Scenes.Lockscreen))
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(isSurfaceBehindVisible).isFalse()

            // Unlocked with fingerprint.
            kosmos.deviceEntryFingerprintAuthRepository.setAuthenticationStatus(
                SuccessFingerprintAuthenticationStatus(0, true)
            )

            // Start the transition to Gone, the surface should not be visible while
            // isUserInputOngoing is true
            val isUserInputOngoing = MutableStateFlow(true)
            kosmos.setSceneTransition(
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Lockscreen,
                    toScene = Scenes.Gone,
                    isInitiatedByUserInput = true,
                    isUserInputOngoing = isUserInputOngoing,
                    progress = flowOf(0.51f),
                    currentScene = flowOf(Scenes.Gone),
                )
            )
            assertThat(isSurfaceBehindVisible).isFalse()

            // When isUserInputOngoing becomes false, then the surface should become visible.
            isUserInputOngoing.value = false
            assertThat(isSurfaceBehindVisible).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun surfaceBehindVisibility_fromBouncerToGone_becomesTrue() =
+0 −34
Original line number Diff line number Diff line
@@ -2118,40 +2118,6 @@ class SceneContainerStartableTest : SysuiTestCase() {
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
        }

    @Test
    fun switchToGone_whenSurfaceBehindLockscreenVisibleMidTransition() =
        testScope.runTest {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val transitionStateFlow =
                prepareState(authenticationMethod = AuthenticationMethodModel.None)
            underTest.start()
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            // Swipe to Gone, more than halfway
            transitionStateFlow.value =
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Lockscreen,
                    toScene = Scenes.Gone,
                    currentScene = flowOf(Scenes.Gone),
                    progress = flowOf(0.51f),
                    isInitiatedByUserInput = true,
                    isUserInputOngoing = flowOf(true),
                )
            runCurrent()
            // Lift finger
            transitionStateFlow.value =
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Lockscreen,
                    toScene = Scenes.Gone,
                    currentScene = flowOf(Scenes.Gone),
                    progress = flowOf(0.51f),
                    isInitiatedByUserInput = true,
                    isUserInputOngoing = flowOf(false),
                )
            runCurrent()

            assertThat(currentScene).isEqualTo(Scenes.Gone)
        }

    @Test
    fun switchToGone_extendUnlock() =
        testScope.runTest {
+1 −8
Original line number Diff line number Diff line
@@ -126,14 +126,7 @@ constructor(
                sceneInteractor.get().transitionState.flatMapLatestConflated { state ->
                    when {
                        state.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Gone) ->
                            (state as Transition).isUserInputOngoing.flatMapLatestConflated {
                                isUserInputOngoing ->
                                if (isUserInputOngoing) {
                            isDeviceEntered
                                } else {
                                    flowOf(true)
                                }
                            }
                        state.isTransitioning(from = Scenes.Bouncer, to = Scenes.Gone) ->
                            (state as Transition).progress.map { progress ->
                                progress >
+0 −24
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import com.android.systemui.deviceentry.shared.model.DeviceUnlockSource
import com.android.systemui.keyguard.DismissCallbackRegistry
import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor
import com.android.systemui.model.SceneContainerPlugin
import com.android.systemui.model.SysUiState
import com.android.systemui.model.updateFlags
@@ -97,7 +96,6 @@ import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.filterNot
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
@@ -138,7 +136,6 @@ constructor(
    private val uiEventLogger: UiEventLogger,
    private val sceneBackInteractor: SceneBackInteractor,
    private val shadeSessionStorage: SessionStorage,
    private val windowMgrLockscreenVisInteractor: WindowManagerLockscreenVisibilityInteractor,
    private val keyguardEnabledInteractor: KeyguardEnabledInteractor,
    private val dismissCallbackRegistry: DismissCallbackRegistry,
    private val statusBarStateController: SysuiStatusBarStateController,
@@ -270,27 +267,6 @@ constructor(
        handleDeviceUnlockStatus()
        handlePowerState()
        handleShadeTouchability()
        handleSurfaceBehindKeyguardVisibility()
    }

    private fun handleSurfaceBehindKeyguardVisibility() {
        applicationScope.launch {
            sceneInteractor.currentScene.collectLatest { currentScene ->
                if (currentScene == Scenes.Lockscreen) {
                    // Wait for the screen to be on
                    powerInteractor.isAwake.first { it }
                    // Wait for surface to become visible
                    windowMgrLockscreenVisInteractor.surfaceBehindVisibility.first { it }
                    // Make sure the device is actually unlocked before force-changing the scene
                    deviceUnlockedInteractor.deviceUnlockStatus.first { it.isUnlocked }
                    // Override the current transition, if any, by forcing the scene to Gone
                    sceneInteractor.changeScene(
                        toScene = Scenes.Gone,
                        loggingReason = "surface behind keyguard is visible",
                    )
                }
            }
        }
    }

    private fun handleBouncerImeVisibility() {
+0 −2
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.haptics.vibratorHelper
import com.android.systemui.keyguard.dismissCallbackRegistry
import com.android.systemui.keyguard.domain.interactor.keyguardEnabledInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.keyguard.domain.interactor.windowManagerLockscreenVisibilityInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testScope
@@ -78,7 +77,6 @@ val Kosmos.sceneContainerStartable by Fixture {
        uiEventLogger = uiEventLogger,
        sceneBackInteractor = sceneBackInteractor,
        shadeSessionStorage = shadeSessionStorage,
        windowMgrLockscreenVisInteractor = windowManagerLockscreenVisibilityInteractor,
        keyguardEnabledInteractor = keyguardEnabledInteractor,
        dismissCallbackRegistry = dismissCallbackRegistry,
        statusBarStateController = sysuiStatusBarStateController,