diff options
| author | 2022-11-29 15:26:35 -0500 | |
|---|---|---|
| committer | 2022-11-30 10:00:07 -0500 | |
| commit | dd3aaa81dc7bcd50bfa8cc87657bdbe9e2b47fdf (patch) | |
| tree | bcb310d507585c9ab006fc2662fe307362520ac4 | |
| parent | b96b7ad9e9db1ea205e7a722c950fa1c38854977 (diff) | |
Prevent touch event dispatch on the top edge when collapsed
For some reason, touch events at y=0 can get dispatched all the
way to Quick Settings, even though it is not visible. This change
prevents that from happening in the most narrow way I could find.
Fixes: 235889526
Test: atest and manual
Change-Id: Iedbb3b55a94864d320b886ba7c29913ad4b8b145
2 files changed, 25 insertions, 14 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 629d3d4d50ba..13ce20cb5822 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -4603,20 +4603,20 @@ public final class NotificationPanelViewController implements Dumpable { return false; } - // If the view that would receive the touch is disabled, just have status bar - // eat the gesture. - if (event.getAction() == MotionEvent.ACTION_DOWN && !mView.isEnabled()) { - Log.v(TAG, - String.format( - "onTouchForwardedFromStatusBar: " - + "panel view disabled, eating touch at (%d,%d)", - (int) event.getX(), - (int) event.getY() - ) - ); - return true; + if (event.getAction() == MotionEvent.ACTION_DOWN) { + // If the view that would receive the touch is disabled, just have status + // bar eat the gesture. + if (!mView.isEnabled()) { + mShadeLog.logMotionEvent(event, + "onTouchForwardedFromStatusBar: panel view disabled"); + return true; + } + if (isFullyCollapsed() && event.getY() < 1f) { + // b/235889526 Eat events on the top edge of the phone when collapsed + mShadeLog.logMotionEvent(event, "top edge touch ignored"); + return true; + } } - return mView.dispatchTouchEvent(event); } }; diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 69a45599668b..f5b3bd081c72 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -831,7 +831,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { public void handleTouchEventFromStatusBar_panelAndViewEnabled_viewReceivesEvent() { when(mCommandQueue.panelsEnabled()).thenReturn(true); when(mView.isEnabled()).thenReturn(true); - MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0); + MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0); mNotificationPanelViewController.getStatusBarTouchEventHandler().handleTouchEvent(event); @@ -839,6 +839,17 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { } @Test + public void handleTouchEventFromStatusBar_topEdgeTouch_viewNeverReceivesEvent() { + when(mCommandQueue.panelsEnabled()).thenReturn(true); + when(mView.isEnabled()).thenReturn(true); + MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0); + + mNotificationPanelViewController.getStatusBarTouchEventHandler().handleTouchEvent(event); + + verify(mView, never()).dispatchTouchEvent(event); + } + + @Test public void testA11y_initializeNode() { AccessibilityNodeInfo nodeInfo = new AccessibilityNodeInfo(); mAccessibilityDelegate.onInitializeAccessibilityNodeInfo(mView, nodeInfo); |