summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author William Xiao <wxyz@google.com> 2024-08-26 18:06:47 -0700
committer William Xiao <wxyz@google.com> 2024-08-28 19:56:31 -0700
commit01757cfe73e48068705bdd680a866869e37deb88 (patch)
tree914f90305091f99a1b69e6ff6eb6ff29bd0de33e
parent00dafb19b8ac03c69f3a325da3264390b72c50f4 (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt10
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt34
2 files changed, 40 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
index 4639e2235346..3bb494b7deca 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
@@ -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) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt
index 5a5cdcd99054..c8ff52ade049 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt
@@ -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()
}
}
@@ -716,6 +720,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) {
testScope.runTest {