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

Commit 81e60723 authored by Chandru S's avatar Chandru S
Browse files

Don't hide all overlays when leaving dream scene if the device is locked.

This fixes dreaming -> bouncer transition on flexiglass.

Bug: 432335857
Test: verified manually
 1. Enroll SFPS
 2. Enable screen saver
 3. Go to screen saver
 4. Auth using SFPS 5 times incorrectly
 5. Dreaming should transition to bouncer without any issues.
Flag: com.android.systemui.scene_container
Change-Id: I10cb8b465aeb54dc886619a708ce02d636688706
parent c299c67c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2383,6 +2383,8 @@ class SceneContainerStartableTest : SysuiTestCase() {
    fun switchFromDreamToLockscreen_whenLockedAndDreamStopped() =
        kosmos.runTest {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)

            prepareState(initialSceneKey = Scenes.Dream)
            underTest.start()
            testScope.advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS)
@@ -2391,11 +2393,19 @@ class SceneContainerStartableTest : SysuiTestCase() {
            testScope.advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS)
            runCurrent()
            assertThat(currentScene).isEqualTo(Scenes.Dream)
            emulateOverlayTransition(
                transitionStateFlow =
                    MutableStateFlow(ObservableTransitionState.Idle(Scenes.Dream)),
                toOverlay = Overlays.Bouncer,
            )
            assertThat(currentOverlays).contains(Overlays.Bouncer)
            runCurrent()

            keyguardInteractor.setDreaming(false)
            testScope.advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS)
            runCurrent()
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            assertThat(currentOverlays).contains(Overlays.Bouncer)
        }

    @Test
+4 −0
Original line number Diff line number Diff line
@@ -183,6 +183,10 @@ constructor(
    val deviceUnlockStatus: StateFlow<DeviceUnlockStatus> =
        repository.deviceUnlockStatus.asStateFlow()

    /** Helper property to check if the device is unlocked. */
    val isUnlocked: Boolean
        get() = deviceUnlockStatus.value.isUnlocked

    /** A [Channel] of "lock now" requests where the values are the debugging reasons. */
    private val lockNowRequests = Channel<String>()

+13 −6
Original line number Diff line number Diff line
@@ -88,6 +88,10 @@ import com.android.systemui.util.println
import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.domain.MSDLPlayer
import dagger.Lazy
import java.io.PrintWriter
import java.util.Optional
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.coroutineScope
@@ -106,10 +110,6 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import dagger.Lazy
import java.io.PrintWriter
import java.util.Optional
import javax.inject.Inject

/**
 * Hooks up business logic that manipulates the state of the [SceneInteractor] for the system UI
@@ -302,9 +302,13 @@ constructor(
                                        is ObservableTransitionState.Idle -> {
                                            if (transitionState.currentScene == Scenes.Dream) {
                                                false to "dream is showing"
                                            } else if (transitionState.currentScene != Scenes.Gone) {
                                            } else if (
                                                transitionState.currentScene != Scenes.Gone
                                            ) {
                                                true to "scene is not Gone"
                                            } else if (transitionState.currentOverlays.isNotEmpty()) {
                                            } else if (
                                                transitionState.currentOverlays.isNotEmpty()
                                            ) {
                                                true to "overlay is shown"
                                            } else {
                                                false to "scene is Gone and no overlays are shown"
@@ -650,6 +654,7 @@ constructor(
                        switchToScene(
                            targetSceneKey = SceneFamilies.Home,
                            loggingReason = "dream stopped",
                            hideAllOverlays = deviceUnlockedInteractor.isUnlocked,
                        )
                    }
                }
@@ -992,12 +997,14 @@ constructor(
        loggingReason: String,
        sceneState: Any? = null,
        freezeAndAnimateToCurrentState: Boolean = false,
        hideAllOverlays: Boolean = true,
    ) {
        sceneInteractor.changeScene(
            toScene = targetSceneKey,
            loggingReason = loggingReason,
            sceneState = sceneState,
            forceSettleToTargetScene = freezeAndAnimateToCurrentState,
            hideAllOverlays = hideAllOverlays,
        )
    }