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

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

Merge changes Ia9ce23a2,I10cb8b46 into main

* changes:
  Map swipe up on dream to go to the lockscreen instead of bouncer.
  Don't hide all overlays when leaving dream scene if the device is locked.
parents 2b1fbb34 02d27ef5
Loading
Loading
Loading
Loading
+3 −6
Original line number Original line Diff line number Diff line
@@ -73,8 +73,7 @@ class DreamUserActionsViewModelTest : SysuiTestCase() {


            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            assertThat(actions).isNotEmpty()
            assertThat(actions).isNotEmpty()
            assertThat(actions?.get(Swipe.Up))
            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Lockscreen))
                .isEqualTo(UserActionResult.ShowOverlay(Overlays.Bouncer))
            assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade))
            assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade))
            assertThat(actions?.get(Swipe.Start)).isNull()
            assertThat(actions?.get(Swipe.Start)).isNull()
            assertThat(actions?.get(Swipe.End)).isNull()
            assertThat(actions?.get(Swipe.End)).isNull()
@@ -99,8 +98,7 @@ class DreamUserActionsViewModelTest : SysuiTestCase() {


            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            assertThat(actions).isNotEmpty()
            assertThat(actions).isNotEmpty()
            assertThat(actions?.get(Swipe.Up))
            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Lockscreen))
                .isEqualTo(UserActionResult.ShowOverlay(Overlays.Bouncer))
            assertThat(actions?.get(Swipe.Down))
            assertThat(actions?.get(Swipe.Down))
                .isEqualTo(UserActionResult(Scenes.Shade, ToSplitShade))
                .isEqualTo(UserActionResult(Scenes.Shade, ToSplitShade))
            assertThat(actions?.get(Swipe.Start)).isNull()
            assertThat(actions?.get(Swipe.Start)).isNull()
@@ -127,8 +125,7 @@ class DreamUserActionsViewModelTest : SysuiTestCase() {


            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            setUpState(isShadeTouchable = true, isDeviceUnlocked = false)
            assertThat(actions).isNotEmpty()
            assertThat(actions).isNotEmpty()
            assertThat(actions?.get(Swipe.Up))
            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Lockscreen))
                .isEqualTo(UserActionResult.ShowOverlay(Overlays.Bouncer))
            assertThat(actions?.get(Swipe.Down))
            assertThat(actions?.get(Swipe.Down))
                .isEqualTo(UserActionResult.ShowOverlay(Overlays.NotificationsShade))
                .isEqualTo(UserActionResult.ShowOverlay(Overlays.NotificationsShade))
            assertThat(actions?.get(Swipe.Start)).isNull()
            assertThat(actions?.get(Swipe.Start)).isNull()
+10 −0
Original line number Original line Diff line number Diff line
@@ -2381,6 +2381,8 @@ class SceneContainerStartableTest : SysuiTestCase() {
    fun switchFromDreamToLockscreen_whenLockedAndDreamStopped() =
    fun switchFromDreamToLockscreen_whenLockedAndDreamStopped() =
        kosmos.runTest {
        kosmos.runTest {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)

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


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


    @Test
    @Test
+4 −0
Original line number Original line Diff line number Diff line
@@ -183,6 +183,10 @@ constructor(
    val deviceUnlockStatus: StateFlow<DeviceUnlockStatus> =
    val deviceUnlockStatus: StateFlow<DeviceUnlockStatus> =
        repository.deviceUnlockStatus.asStateFlow()
        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. */
    /** A [Channel] of "lock now" requests where the values are the debugging reasons. */
    private val lockNowRequests = Channel<String>()
    private val lockNowRequests = Channel<String>()


+1 −2
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.compose.animation.scene.UserActionResult
import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.viewmodel.UserActionsViewModel
import com.android.systemui.scene.ui.viewmodel.UserActionsViewModel
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.domain.interactor.ShadeInteractor
@@ -59,7 +58,7 @@ constructor(
                                if (isDeviceUnlocked) {
                                if (isDeviceUnlocked) {
                                    add(Swipe.Up to Scenes.Gone)
                                    add(Swipe.Up to Scenes.Gone)
                                } else {
                                } else {
                                    add(Swipe.Up to Overlays.Bouncer)
                                    add(Swipe.Up to Scenes.Lockscreen)
                                }
                                }


                                addAll(
                                addAll(
+13 −6
Original line number Original line 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.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.domain.MSDLPlayer
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.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.coroutineScope
@@ -106,10 +110,6 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
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
 * Hooks up business logic that manipulates the state of the [SceneInteractor] for the system UI
@@ -302,9 +302,13 @@ constructor(
                                        is ObservableTransitionState.Idle -> {
                                        is ObservableTransitionState.Idle -> {
                                            if (transitionState.currentScene == Scenes.Dream) {
                                            if (transitionState.currentScene == Scenes.Dream) {
                                                false to "dream is showing"
                                                false to "dream is showing"
                                            } else if (transitionState.currentScene != Scenes.Gone) {
                                            } else if (
                                                transitionState.currentScene != Scenes.Gone
                                            ) {
                                                true to "scene is not Gone"
                                                true to "scene is not Gone"
                                            } else if (transitionState.currentOverlays.isNotEmpty()) {
                                            } else if (
                                                transitionState.currentOverlays.isNotEmpty()
                                            ) {
                                                true to "overlay is shown"
                                                true to "overlay is shown"
                                            } else {
                                            } else {
                                                false to "scene is Gone and no overlays are shown"
                                                false to "scene is Gone and no overlays are shown"
@@ -650,6 +654,7 @@ constructor(
                        switchToScene(
                        switchToScene(
                            targetSceneKey = SceneFamilies.Home,
                            targetSceneKey = SceneFamilies.Home,
                            loggingReason = "dream stopped",
                            loggingReason = "dream stopped",
                            hideAllOverlays = deviceUnlockedInteractor.isUnlocked,
                        )
                        )
                    }
                    }
                }
                }
@@ -992,12 +997,14 @@ constructor(
        loggingReason: String,
        loggingReason: String,
        sceneState: Any? = null,
        sceneState: Any? = null,
        freezeAndAnimateToCurrentState: Boolean = false,
        freezeAndAnimateToCurrentState: Boolean = false,
        hideAllOverlays: Boolean = true,
    ) {
    ) {
        sceneInteractor.changeScene(
        sceneInteractor.changeScene(
            toScene = targetSceneKey,
            toScene = targetSceneKey,
            loggingReason = loggingReason,
            loggingReason = loggingReason,
            sceneState = sceneState,
            sceneState = sceneState,
            forceSettleToTargetScene = freezeAndAnimateToCurrentState,
            forceSettleToTargetScene = freezeAndAnimateToCurrentState,
            hideAllOverlays = hideAllOverlays,
        )
        )
    }
    }