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

Commit 03f010f4 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Fixes crash when opening QS from Shade

Gotta filter backScene to not ever emit the same scene from that scene's
view-model. Other scenes that use backScene already do this.

Fix: 370962149
Test: manually verified that the crash no longer occurs
Test: unit test added to reproduce the failure and it no longer
reproduces after the fix
Flag: com.android.systemui.scene_container

Change-Id: I4e643ed6116b0694af524f6532d09f84e9f0a83d
parent 7383d91f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.flags.EnableSceneContainer
@@ -50,6 +51,7 @@ import com.android.systemui.shade.domain.startable.shadeStartable
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.TestScope
@@ -248,6 +250,27 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() {
            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Communal))
        }

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

            kosmos.sceneInteractor.changeScene(Scenes.QuickSettings, "")
            assertThat(currentScene).isEqualTo(Scenes.QuickSettings)

            actions.forEachIndexed { index, map ->
                assertWithMessage(
                        "Actions on index $index is incorrectly mapping back to the Shade scene!"
                    )
                    .that((map[Swipe.Up] as? UserActionResult.ChangeScene)?.toScene)
                    .isNotEqualTo(Scenes.Shade)
            }
        }

    private fun TestScope.setDeviceEntered(isEntered: Boolean) {
        if (isEntered) {
            // Unlock the device marking the device has entered.
+4 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.shade.shared.model.ShadeMode
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter

/**
 * Models the UI state for the user actions that the user can perform to navigate to other scenes.
@@ -50,7 +51,9 @@ constructor(
        combine(
                shadeInteractor.shadeMode,
                qsSceneAdapter.isCustomizerShowing,
                sceneBackInteractor.backScene.map { it ?: SceneFamilies.Home },
                sceneBackInteractor.backScene
                    .filter { it != Scenes.Shade }
                    .map { it ?: SceneFamilies.Home },
            ) { shadeMode, isCustomizerShowing, backScene ->
                buildMap<UserAction, UserActionResult> {
                    if (!isCustomizerShowing) {