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

Commit 72767254 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Fix glanceable hub touch handler processing touches when closing shade on dream" into main

parents 61962e5c 01757cfe
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) {