From 5b73655fb2194ae77bb9727bf053571983ab3195 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 11 Oct 2022 18:56:44 +0000 Subject: [PATCH] Don't send touches to PanelViewController when pulsing Test: atest NotificationPanelViewControllerTest Test: 1. Setup PIN security 2. receive a pulsing notification when the display is off, 3. swipe downward on the notification => see that it can expand to the notification shade Test: 1. Setup PIN security 2. Receive a pulsing notification when the display is off, 3. Swipe down and up below the notification => see there are no bouncer or panel expansion changes Test: 1. Setup face auth with BYPASS 2. Receive a pulsing notification when the display is off 3. Swipe downward anywhere on the display => see the notification shade expands, but other swipes (ie: up) don't bring up the bouncer Test: Tests the above scenarios with "Sensitive notifications" NOT allowed. Fixes: 236443196 Change-Id: I126b7d7cf7d60cfc3fece28b2c5d7c068fb39c39 --- .../NotificationPanelViewController.java | 6 +++- .../statusbar/PulseExpansionHandler.kt | 7 ++-- .../NotificationPanelViewControllerTest.java | 34 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e3318127af931..200579ad17cec 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -6051,6 +6051,10 @@ public final class NotificationPanelViewController { mShadeLog.logMotionEvent(event, "onTouch: PulseExpansionHandler handled event"); return true; } + if (mPulsing) { + mShadeLog.logMotionEvent(event, "onTouch: eat touch, device pulsing"); + return true; + } if (mListenForHeadsUp && !mHeadsUpTouchHelper.isTrackingHeadsUp() && !mNotificationStackScrollLayoutController.isLongPressInProgress() && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { @@ -6073,7 +6077,7 @@ public final class NotificationPanelViewController { } handled |= handleTouch(event); - return !mDozing || mPulsing || handled; + return !mDozing || handled; } private boolean handleTouch(MotionEvent event) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt index bbff0466cf50c..8222c9d9ba59f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt @@ -52,7 +52,10 @@ import javax.inject.Inject import kotlin.math.max /** - * A utility class to enable the downward swipe on when pulsing. + * A utility class that handles notification panel expansion when a user swipes downward on a + * notification from the pulsing state. + * If face-bypass is enabled, the user can swipe down anywhere on the screen (not just from a + * notification) to trigger the notification panel expansion. */ @SysUISingleton class PulseExpansionHandler @Inject @@ -62,7 +65,7 @@ constructor( private val bypassController: KeyguardBypassController, private val headsUpManager: HeadsUpManagerPhone, private val roundnessManager: NotificationRoundnessManager, - private val configurationController: ConfigurationController, + configurationController: ConfigurationController, private val statusBarStateController: StatusBarStateController, private val falsingManager: FalsingManager, private val lockscreenShadeTransitionController: LockscreenShadeTransitionController, 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 37be3439fdc8b..c0dae03023c59 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -715,6 +715,40 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { assertThat(mNotificationPanelViewController.isTrackingBlocked()).isFalse(); } + @Test + public void test_pulsing_onTouchEvent_noTracking() { + // GIVEN device is pulsing + mNotificationPanelViewController.setPulsing(true); + + // WHEN touch DOWN & MOVE events received + onTouchEvent(MotionEvent.obtain(0L /* downTime */, + 0L /* eventTime */, MotionEvent.ACTION_DOWN, 0f /* x */, 0f /* y */, + 0 /* metaState */)); + onTouchEvent(MotionEvent.obtain(0L /* downTime */, + 0L /* eventTime */, MotionEvent.ACTION_MOVE, 0f /* x */, 200f /* y */, + 0 /* metaState */)); + + // THEN touch is NOT tracked (since the device is pulsing) + assertThat(mNotificationPanelViewController.isTracking()).isFalse(); + } + + @Test + public void test_onTouchEvent_startTracking() { + // GIVEN device is NOT pulsing + mNotificationPanelViewController.setPulsing(false); + + // WHEN touch DOWN & MOVE events received + onTouchEvent(MotionEvent.obtain(0L /* downTime */, + 0L /* eventTime */, MotionEvent.ACTION_DOWN, 0f /* x */, 0f /* y */, + 0 /* metaState */)); + onTouchEvent(MotionEvent.obtain(0L /* downTime */, + 0L /* eventTime */, MotionEvent.ACTION_MOVE, 0f /* x */, 200f /* y */, + 0 /* metaState */)); + + // THEN touch is tracked + assertThat(mNotificationPanelViewController.isTracking()).isTrue(); + } + @Test public void handleTouchEventFromStatusBar_panelsNotEnabled_returnsFalseAndNoViewEvent() { when(mCommandQueue.panelsEnabled()).thenReturn(false);