From bd707492a2ef3641a9e9a64ef72b3b031dac0bb6 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 10 May 2017 17:51:25 -0700 Subject: [PATCH] Check for false touches when determining if the notif menu should be shown If it's a false touch don't show the menu. Test: manual: try swiping things away on the lockscreen (fast + long) try showing notification menu on the lockscreen Bug: 38208094 Change-Id: I16ceedd90a5fbc80156a9495d6cfd6fa02771886 --- .../statusbar/NotificationSwipeActionHelper.java | 2 ++ .../SystemUI/src/com/android/systemui/SwipeHelper.java | 10 +++++++--- .../systemui/statusbar/NotificationMenuRow.java | 3 ++- .../statusbar/stack/NotificationStackScrollLayout.java | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java index 4ce1e36bde3ae..3cd5d89ea1425 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java @@ -49,6 +49,8 @@ public interface NotificationSwipeActionHelper { public boolean isDismissGesture(MotionEvent ev); + public boolean isFalseGesture(MotionEvent ev); + public boolean swipedFarEnough(float translation, float viewSize); public boolean swipedFastEnough(float translation, float velocity); diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 9c03ea6adc5fd..74b745f3eeec9 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -653,15 +653,19 @@ public class SwipeHelper implements Gefingerpoken { } public boolean isDismissGesture(MotionEvent ev) { + return ev.getActionMasked() == MotionEvent.ACTION_UP + && !isFalseGesture(ev) && (swipedFastEnough() || swipedFarEnough()) + && mCallback.canChildBeDismissed(mCurrView); + } + + public boolean isFalseGesture(MotionEvent ev) { boolean falsingDetected = mCallback.isAntiFalsingNeeded(); if (mFalsingManager.isClassiferEnabled()) { falsingDetected = falsingDetected && mFalsingManager.isFalseTouch(); } else { falsingDetected = falsingDetected && !mTouchAboveFalsingThreshold; } - return !falsingDetected && (swipedFastEnough() || swipedFarEnough()) - && ev.getActionMasked() == MotionEvent.ACTION_UP - && mCallback.canChildBeDismissed(mCurrView); + return falsingDetected; } protected boolean swipedFastEnough() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java index d4b892064980b..d6abf47da0c06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java @@ -330,7 +330,8 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } else { snapBack(animView, velocity); } - } else if ((swipedEnoughToShowMenu() && (!gestureFastEnough || showMenuForSlowOnGoing)) + } else if (!mSwipeHelper.isFalseGesture(ev) + && (swipedEnoughToShowMenu() && (!gestureFastEnough || showMenuForSlowOnGoing)) || (gestureTowardsMenu && !mSwipeHelper.isDismissGesture(ev))) { // Menu has not been snapped to previously and this is menu revealing gesture showMenu(animView, menuSnapTarget, velocity); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 2f7a4ed5afdb1..cce0f81608f73 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -4351,6 +4351,10 @@ public class NotificationStackScrollLayout extends ViewGroup mStatusBar.setNotificationSnoozed(sbn, snoozeOption); } + public boolean isFalseGesture(MotionEvent ev) { + return super.isFalseGesture(ev); + } + private void handleMenuCoveredOrDismissed() { if (mMenuExposedView != null && mMenuExposedView == mTranslatingParentView) { mMenuExposedView = null;