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

Commit ce9677df authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] The shade scene returns to Communal if it came from there

Bug: 323068793
Test: manually verified that swiping up on the shade returns to the
right scene. If it came from Lockscreen, it goes back to lockscreen, if
it came from Gone, it goes back there, and most importantly, if it comes
from Communal - you guessed it :)
Test: unit test added
Flag: com.android.systemui.scene_container

Change-Id: I02b05703de5a4a2695e687c1db4d52cff65ddcdb
parent 5c49ad48
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -50,9 +50,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.resolver.homeSceneFamilyResolver
import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.shared.model.SceneFamilies
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
@@ -185,7 +183,6 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
    fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenNotDismissed_goesToLockscreen() =
        testScope.runTest {
            val actions by collectLastValue(kosmos.shadeUserActionsViewModel.actions)
            val homeScene by collectLastValue(kosmos.homeSceneFamilyResolver.resolvedScene)
            kosmos.setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
            kosmos.assertCurrentScene(Scenes.Lockscreen)

@@ -195,9 +192,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {

            val upDestinationSceneKey =
                (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene
            assertThat(upDestinationSceneKey).isEqualTo(SceneFamilies.Home)
            assertThat(homeScene).isEqualTo(Scenes.Lockscreen)
            kosmos.emulateUserDrivenTransition(to = homeScene)
            assertThat(upDestinationSceneKey).isEqualTo(Scenes.Lockscreen)
            kosmos.emulateUserDrivenTransition(to = Scenes.Lockscreen)
        }

    @Test
@@ -205,7 +201,6 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
        testScope.runTest {
            val actions by collectLastValue(kosmos.shadeUserActionsViewModel.actions)
            val canSwipeToEnter by collectLastValue(kosmos.deviceEntryInteractor.canSwipeToEnter)
            val homeScene by collectLastValue(kosmos.homeSceneFamilyResolver.resolvedScene)

            kosmos.setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)

@@ -222,9 +217,8 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {

            val upDestinationSceneKey =
                (actions?.get(Swipe.Up) as? UserActionResult.ChangeScene)?.toScene
            assertThat(upDestinationSceneKey).isEqualTo(SceneFamilies.Home)
            assertThat(homeScene).isEqualTo(Scenes.Gone)
            kosmos.emulateUserDrivenTransition(to = homeScene)
            assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone)
            kosmos.emulateUserDrivenTransition(to = Scenes.Gone)
        }

    @Test
+16 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.qs.ui.adapter.fakeQSSceneAdapter
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.resolver.homeSceneFamilyResolver
import com.android.systemui.scene.domain.startable.sceneContainerStartable
import com.android.systemui.scene.shared.model.SceneFamilies
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
@@ -76,6 +77,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() {

    @Before
    fun setUp() {
        kosmos.sceneContainerStartable.start()
        underTest.activateIn(testScope)
    }

@@ -232,6 +234,20 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() {
                .isEmpty()
        }

    @Test
    fun upTransitionSceneKey_backToCommunal() =
        testScope.runTest {
            val actions by collectLastValue(underTest.actions)
            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            kosmos.sceneInteractor.changeScene(Scenes.Communal, "")
            assertThat(currentScene).isEqualTo(Scenes.Communal)
            kosmos.sceneInteractor.changeScene(Scenes.Shade, "")
            assertThat(currentScene).isEqualTo(Scenes.Shade)

            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Communal))
        }

    private fun TestScope.setDeviceEntered(isEntered: Boolean) {
        if (isEntered) {
            // Unlock the device marking the device has entered.
+8 −4
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

package com.android.systemui.shade.ui.viewmodel

import com.android.app.tracing.coroutines.flow.map
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.SwipeDirection
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.scene.domain.interactor.SceneBackInteractor
import com.android.systemui.scene.shared.model.SceneFamilies
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
@@ -41,21 +43,23 @@ class ShadeUserActionsViewModel
constructor(
    private val qsSceneAdapter: QSSceneAdapter,
    private val shadeInteractor: ShadeInteractor,
    private val sceneBackInteractor: SceneBackInteractor,
) : UserActionsViewModel() {

    override suspend fun hydrateActions(setActions: (Map<UserAction, UserActionResult>) -> Unit) {
        combine(
                shadeInteractor.shadeMode,
                qsSceneAdapter.isCustomizerShowing,
            ) { shadeMode, isCustomizerShowing ->
                sceneBackInteractor.backScene.map { it ?: SceneFamilies.Home },
            ) { shadeMode, isCustomizerShowing, backScene ->
                buildMap<UserAction, UserActionResult> {
                    if (!isCustomizerShowing) {
                        set(
                            Swipe(SwipeDirection.Up),
                            UserActionResult(
                                SceneFamilies.Home,
                                ToSplitShade.takeIf { shadeMode is ShadeMode.Split }
                            )
                                backScene,
                                ToSplitShade.takeIf { shadeMode is ShadeMode.Split },
                            ),
                        )
                    }

+2 −0
Original line number Diff line number Diff line
@@ -19,11 +19,13 @@ package com.android.systemui.shade.ui.viewmodel
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.qs.ui.adapter.qsSceneAdapter
import com.android.systemui.scene.domain.interactor.sceneBackInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor

val Kosmos.shadeUserActionsViewModel: ShadeUserActionsViewModel by Fixture {
    ShadeUserActionsViewModel(
        qsSceneAdapter = qsSceneAdapter,
        shadeInteractor = shadeInteractor,
        sceneBackInteractor = sceneBackInteractor,
    )
}