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

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

[flexiglass] Scene container no longer visible after canceled swipe.

When unlocked, if we swipe down a short distance to reveal the shade
but stop short such that the shade never shows, Flexiglass' scene
container remains visible forever.

This CL fixes that.

Test: unit and integration tests
Test: manually verified that the scene container no longer gets stuck in
this condition
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT

Change-Id: I5ea7f428635000dc9d1063479c4abab5ce7bef2d
parent 9b5695a0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -615,6 +615,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
    private fun TestScope.emulatePendingTransitionProgress(
        expectedVisible: Boolean = true,
    ) {
        val isVisible by collectLastValue(sceneContainerViewModel.isVisible)
        assertWithMessage("The FakeSceneDataSource has to be paused for this to do anything.")
            .that(fakeSceneDataSource.isPaused)
            .isTrue()
@@ -651,7 +652,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
        runCurrent()

        assertWithMessage("Visibility mismatch after scene transition from $from to $to!")
            .that(sceneContainerViewModel.isVisible.value)
            .that(isVisible)
            .isEqualTo(expectedVisible)
        assertThat(sceneContainerViewModel.currentScene.value).isEqualTo(to)

+17 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.android.systemui.scene.domain.interactor

import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -31,6 +33,7 @@ import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runCurrent
@@ -275,4 +278,18 @@ class SceneInteractorTest : SysuiTestCase() {
            underTest.setVisible(true, "reason")
            assertThat(isVisible).isTrue()
        }

    @Test
    fun isVisible_duringRemoteUserInteraction_forcedVisible() =
        testScope.runTest {
            underTest.setVisible(false, "reason")
            val isVisible by collectLastValue(underTest.isVisible)
            assertThat(isVisible).isFalse()
            underTest.onRemoteUserInteractionStarted("reason")
            assertThat(isVisible).isTrue()

            underTest.onUserInteractionFinished()

            assertThat(isVisible).isFalse()
        }
}
+22 −7
Original line number Diff line number Diff line
@@ -14,10 +14,9 @@
 * limitations under the License.
 */

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.android.systemui.scene.ui.viewmodel

import android.view.MotionEvent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -35,9 +34,9 @@ import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -50,7 +49,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope by lazy { kosmos.testScope }
    private val interactor by lazy { kosmos.sceneInteractor }
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val fakeSceneDataSource = kosmos.fakeSceneDataSource
    private val sceneContainerConfig = kosmos.sceneContainerConfig
    private val falsingManager = kosmos.fakeFalsingManager
@@ -62,7 +61,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
        kosmos.fakeSceneContainerFlags.enabled = true
        underTest =
            SceneContainerViewModel(
                sceneInteractor = interactor,
                sceneInteractor = sceneInteractor,
                falsingInteractor = kosmos.falsingInteractor,
                powerInteractor = kosmos.powerInteractor,
            )
@@ -74,10 +73,10 @@ class SceneContainerViewModelTest : SysuiTestCase() {
            val isVisible by collectLastValue(underTest.isVisible)
            assertThat(isVisible).isTrue()

            interactor.setVisible(false, "reason")
            sceneInteractor.setVisible(false, "reason")
            assertThat(isVisible).isFalse()

            interactor.setVisible(true, "reason")
            sceneInteractor.setVisible(true, "reason")
            assertThat(isVisible).isTrue()
        }

@@ -199,4 +198,20 @@ class SceneContainerViewModelTest : SysuiTestCase() {
            underTest.onMotionEvent(mock())
            assertThat(kosmos.fakePowerRepository.userTouchRegistered).isTrue()
        }

    @Test
    fun remoteUserInteraction_keepsContainerVisible() =
        testScope.runTest {
            sceneInteractor.setVisible(false, "reason")
            val isVisible by collectLastValue(underTest.isVisible)
            assertThat(isVisible).isFalse()
            sceneInteractor.onRemoteUserInteractionStarted("reason")
            assertThat(isVisible).isTrue()

            underTest.onMotionEvent(
                mock { whenever(actionMasked).thenReturn(MotionEvent.ACTION_UP) }
            )

            assertThat(isVisible).isFalse()
        }
}
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                        // If scene framework is enabled, set the scene container window to
                        // visible and let the touch "slip" into that window.
                        if (mSceneContainerFlags.isEnabled()) {
                            mSceneInteractor.get().setVisible(true, "swipe down on launcher");
                            mSceneInteractor.get().onRemoteUserInteractionStarted("launcher swipe");
                        } else {
                            mShadeViewControllerLazy.get().startInputFocusTransfer();
                        }
+7 −0
Original line number Diff line number Diff line
@@ -49,6 +49,13 @@ constructor(
    private val _isVisible = MutableStateFlow(true)
    val isVisible: StateFlow<Boolean> = _isVisible.asStateFlow()

    /**
     * Whether there's an ongoing remotely-initiated user interaction.
     *
     * For more information see the logic in `SceneInteractor` that mutates this.
     */
    val isRemoteUserInteractionOngoing = MutableStateFlow(false)

    private val defaultTransitionState = ObservableTransitionState.Idle(config.initialSceneKey)
    private val _transitionState = MutableStateFlow<Flow<ObservableTransitionState>?>(null)
    val transitionState: StateFlow<ObservableTransitionState> =
Loading