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

Commit 8c690459 authored by William Xiao's avatar William Xiao
Browse files

Fix hub touch handling breaking after using gestures on hub over dream

The DreamOverlayService has its own TouchMonitor that needs to be shut
off once the glanceable hub shows up. If the dream starts underneath
the hub, such as if you dock while the hub is open, or if we restart
the dream under the hub, this is not done correctly.

This causes touch handlers for both the hub and the dream to run when
performing gestures over the hub, which leads to touch sessions getting
stuck and stop all subsequent gestures from working.

This changes the logic in DreamOverlayService to not always set its
lifecycle state to RESUMED once dreaming starts, which turns on touch
monitoring, but instead sets it conditionally based on whether or not
anything is covering the dream.

Bug: 337094073
Fix: 337094073
Test: atest DreamOverlayServiceTest
      also verified manually that touch handling works on and off dream
Flag: ACONFIG com.android.systemui.communal_hub TEAMFOOD
Change-Id: I59b941889b67e5daf491be2ae2c77934698d7d19
parent 64fed7b8
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -689,6 +689,31 @@ class DreamOverlayServiceTest : SysuiTestCase() {
            )
    }

    // Verifies that the touch handling lifecycle is STARTED even if the dream starts while not
    // focused.
    @Test
    fun testLifecycle_dreamNotFocusedOnStart_isStarted() {
        val transitionState: MutableStateFlow<ObservableTransitionState> =
            MutableStateFlow(ObservableTransitionState.Idle(CommunalScenes.Blank))
        communalRepository.setTransitionState(transitionState)

        // Communal becomes visible.
        transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal)
        testScope.runCurrent()
        mMainExecutor.runAllReady()

        // Start dreaming.
        val client = client
        client.startDream(
            mWindowParams,
            mDreamOverlayCallback,
            DREAM_COMPONENT,
            false /*shouldShowComplication*/
        )
        mMainExecutor.runAllReady()
        assertThat(lifecycleRegistry.currentState).isEqualTo(Lifecycle.State.STARTED)
    }

    @Test
    fun testLifecycle_destroyedAfterOnDestroy() {
        val client = client
+3 −1
Original line number Diff line number Diff line
@@ -359,7 +359,9 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
            return;
        }

        setLifecycleStateLocked(Lifecycle.State.RESUMED);
        // Set lifecycle to resumed only if there's nothing covering the dream, ex. shade, bouncer,
        // or hub. These updates can come in before onStartDream runs.
        updateLifecycleStateLocked();
        mStateController.setOverlayActive(true);
        final ComponentName dreamComponent = getDreamComponent();
        mStateController.setLowLightActive(