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

Commit 01757cfe authored by William Xiao's avatar William Xiao
Browse files

Fix glanceable hub touch handler processing touches when closing shade on dream

The glanceable hub currently only refrains from processing touches when
the shade is fully open. When closing the shade on the dream, touches
after the shade is partially closed will be processed as the shade is
no longer fully expanded. This leads to the communal container
receiving partial gestures, such as move events without down events.

This fixes an issue where slowly closing the shade over the hub on
dream, ie. with a drag not a fling, causes the shade to be stuck open
and keep stealing touches.

Bug: 361091641
Test: atest GlanceableHubContainerControllerTest
Flag: com.android.systemui.communal_hub
Change-Id: Ic254e551e396f10b9451ba927a9b93fa7e848237
parent 00dafb19
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -203,6 +203,13 @@ constructor(
     */
    private var shadeConsumingTouches = false

    /**
     * True if the shade is showing at all.
     *
     * Inverse of [ShadeInteractor.isShadeFullyCollapsed]
     */
    private var shadeShowing = false

    /** True if the keyguard transition state is finished on [KeyguardState.LOCKSCREEN]. */
    private var onLockscreen = false

@@ -414,6 +421,7 @@ constructor(
            ),
            { (isFullyExpanded, isUserInteracting, isShadeFullyCollapsed) ->
                shadeConsumingTouches = isUserInteracting
                shadeShowing = !isShadeFullyCollapsed
                val expandedAndNotInteractive = isFullyExpanded && !isUserInteracting

                // If we ever are fully expanded and not interacting, capture this state as we
@@ -529,7 +537,7 @@ constructor(
        val isMove = ev.actionMasked == MotionEvent.ACTION_MOVE
        val isCancel = ev.actionMasked == MotionEvent.ACTION_CANCEL

        val hubOccluded = anyBouncerShowing || shadeShowingAndConsumingTouches
        val hubOccluded = anyBouncerShowing || shadeConsumingTouches || shadeShowing

        if ((isDown || isMove) && !hubOccluded) {
            if (isDown) {
+31 −3
Original line number Diff line number Diff line
@@ -417,13 +417,17 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
                // Communal is open.
                goToScene(CommunalScenes.Communal)

                // Shade shows up.
                shadeTestUtil.setQsExpansion(0.5f)
                testableLooper.processAllMessages()
                // Touch starts and ends.
                assertThat(underTest.onTouchEvent(DOWN_EVENT)).isTrue()
                assertThat(underTest.onTouchEvent(CANCEL_EVENT)).isTrue()

                // Up event is no longer processed
                assertThat(underTest.onTouchEvent(UP_EVENT)).isFalse()

                // Move event can still be processed
                assertThat(underTest.onTouchEvent(MOVE_EVENT)).isTrue()
                assertThat(underTest.onTouchEvent(MOVE_EVENT)).isTrue()
                assertThat(underTest.onTouchEvent(UP_EVENT)).isTrue()
            }
        }

@@ -715,6 +719,30 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
            }
        }

    @Test
    fun onTouchEvent_shadeExpanding_touchesNotDispatched() =
        with(kosmos) {
            testScope.runTest {
                // On lockscreen.
                goToScene(CommunalScenes.Blank)
                whenever(
                        notificationStackScrollLayoutController.isBelowLastNotification(
                            any(),
                            any()
                        )
                    )
                    .thenReturn(true)

                // Shade is open slightly.
                fakeShadeRepository.setLegacyShadeExpansion(0.01f)
                testableLooper.processAllMessages()

                // Touches are not consumed.
                assertThat(underTest.onTouchEvent(DOWN_EVENT)).isFalse()
                verify(containerView, never()).onTouchEvent(DOWN_EVENT)
            }
        }

    @Test
    fun onTouchEvent_bouncerInteracting_movesNotDispatched() =
        with(kosmos) {