From a93dc19b722274f06ef13627b3b02b625dd7e627 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Mon, 5 Apr 2021 17:13:25 -0400 Subject: [PATCH] Analyze Falsing on Expanded Notif Shade. Ensure that gestures on the expanded notification shade are picked up properly by the FalsingManager. This adds `SHADE_DRAG` and `QS_COLLAPSE` falsing interaction types to cover these cases. Also, try to limit calling on the FalsingManager until a gesture is actually ready to occur, instead of querying it while deciding what the current gesture is. Fixes: 184042853 Test: manual Change-Id: I1f651614d4d1520bac1a2375319f69fb1017505f --- .../systemui/classifier/Classifier.java | 9 +++++-- .../classifier/DistanceClassifier.java | 7 +++++- .../classifier/ProximityClassifier.java | 4 +++- .../systemui/classifier/TypeClassifier.java | 8 +++++++ .../systemui/classifier/ZigZagClassifier.java | 3 ++- .../systemui/statusbar/DragDownHelper.java | 11 +++++---- .../stack/NotificationStackScrollLayout.java | 15 ++++++------ ...tificationStackScrollLayoutController.java | 8 +++++++ .../NotificationPanelViewController.java | 24 +++++++++---------- .../statusbar/phone/PanelViewController.java | 7 +++--- .../systemui/statusbar/phone/StatusBar.java | 2 +- ...tificationStackScrollerControllerTest.java | 2 ++ 12 files changed, 67 insertions(+), 33 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/classifier/Classifier.java b/packages/SystemUI/src/com/android/systemui/classifier/Classifier.java index 4dd8780eb7ab8..6a012ebdd1e7a 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/Classifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/Classifier.java @@ -38,8 +38,10 @@ public abstract class Classifier { public static final int BOUNCER_UNLOCK = 8; public static final int PULSE_EXPAND = 9; public static final int BRIGHTNESS_SLIDER = 10; - public static final int UDFPS_AUTHENTICATION = 11; - public static final int DISABLED_UDFPS_AFFORDANCE = 12; + public static final int SHADE_DRAG = 11; + public static final int QS_COLLAPSE = 12; + public static final int UDFPS_AUTHENTICATION = 13; + public static final int DISABLED_UDFPS_AFFORDANCE = 14; @IntDef({ QUICK_SETTINGS, @@ -53,6 +55,9 @@ public abstract class Classifier { BOUNCER_UNLOCK, PULSE_EXPAND, BRIGHTNESS_SLIDER, + SHADE_DRAG, + QS_COLLAPSE, + BRIGHTNESS_SLIDER, UDFPS_AUTHENTICATION, DISABLED_UDFPS_AFFORDANCE }) diff --git a/packages/SystemUI/src/com/android/systemui/classifier/DistanceClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/DistanceClassifier.java index 6a70622247568..a4e1637e0de06 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/DistanceClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/DistanceClassifier.java @@ -22,6 +22,9 @@ import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHT import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VELOCITY_TO_DISTANCE; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VERTICAL_FLING_THRESHOLD_IN; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VERTICAL_SWIPE_THRESHOLD_IN; +import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER; +import static com.android.systemui.classifier.Classifier.QS_COLLAPSE; +import static com.android.systemui.classifier.Classifier.SHADE_DRAG; import android.provider.DeviceConfig; import android.view.MotionEvent; @@ -148,7 +151,9 @@ class DistanceClassifier extends FalsingClassifier { Result calculateFalsingResult( @Classifier.InteractionType int interactionType, double historyBelief, double historyConfidence) { - if (interactionType == Classifier.BRIGHTNESS_SLIDER + if (interactionType == BRIGHTNESS_SLIDER + || interactionType == SHADE_DRAG + || interactionType == QS_COLLAPSE || interactionType == Classifier.UDFPS_AUTHENTICATION || interactionType == Classifier.DISABLED_UDFPS_AFFORDANCE) { return Result.passed(0); diff --git a/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java index 6f80010863c2b..3bc24c734a606 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java @@ -18,6 +18,7 @@ package com.android.systemui.classifier; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD; import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER; +import static com.android.systemui.classifier.Classifier.QS_COLLAPSE; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import android.provider.DeviceConfig; @@ -116,7 +117,8 @@ class ProximityClassifier extends FalsingClassifier { Result calculateFalsingResult( @Classifier.InteractionType int interactionType, double historyBelief, double historyConfidence) { - if (interactionType == QUICK_SETTINGS || interactionType == BRIGHTNESS_SLIDER) { + if (interactionType == QUICK_SETTINGS || interactionType == BRIGHTNESS_SLIDER + || interactionType == QS_COLLAPSE) { return Result.passed(0); } diff --git a/packages/SystemUI/src/com/android/systemui/classifier/TypeClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/TypeClassifier.java index 50e94b3e03c25..1042516ebecfc 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/TypeClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/TypeClassifier.java @@ -23,8 +23,10 @@ import static com.android.systemui.classifier.Classifier.LEFT_AFFORDANCE; import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS; import static com.android.systemui.classifier.Classifier.NOTIFICATION_DRAG_DOWN; import static com.android.systemui.classifier.Classifier.PULSE_EXPAND; +import static com.android.systemui.classifier.Classifier.QS_COLLAPSE; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.classifier.Classifier.RIGHT_AFFORDANCE; +import static com.android.systemui.classifier.Classifier.SHADE_DRAG; import static com.android.systemui.classifier.Classifier.UNLOCK; import javax.inject.Inject; @@ -77,6 +79,12 @@ public class TypeClassifier extends FalsingClassifier { case RIGHT_AFFORDANCE: // Swiping from the bottom right corner for camera or similar. wrongDirection = right || !up; break; + case SHADE_DRAG: + wrongDirection = !vertical; + break; + case QS_COLLAPSE: + wrongDirection = !vertical || !up; + break; default: wrongDirection = true; break; diff --git a/packages/SystemUI/src/com/android/systemui/classifier/ZigZagClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/ZigZagClassifier.java index d9197ef830587..e1349f2aba6da 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/ZigZagClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/ZigZagClassifier.java @@ -21,6 +21,7 @@ import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHT import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE; import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE; import static com.android.systemui.classifier.Classifier.BRIGHTNESS_SLIDER; +import static com.android.systemui.classifier.Classifier.SHADE_DRAG; import android.graphics.Point; import android.provider.DeviceConfig; @@ -88,7 +89,7 @@ class ZigZagClassifier extends FalsingClassifier { Result calculateFalsingResult( @Classifier.InteractionType int interactionType, double historyBelief, double historyConfidence) { - if (interactionType == BRIGHTNESS_SLIDER) { + if (interactionType == BRIGHTNESS_SLIDER || interactionType == SHADE_DRAG) { return Result.passed(0); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java index 7ef88bb0c2c83..5cebf7c04b7e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java @@ -142,9 +142,9 @@ public class DragDownHelper implements Gefingerpoken { } return true; case MotionEvent.ACTION_UP: - if (!mFalsingManager.isUnlockingDisabled() && !isFalseTouch() - && mDragDownCallback.onDraggedDown(mStartingChild, - (int) (y - mInitialTouchY))) { + if (!mFalsingManager.isUnlockingDisabled() && mDragDownCallback.canDragDown() + && !isFalseTouch()) { + mDragDownCallback.onDraggedDown(mStartingChild, (int) (y - mInitialTouchY)); if (mStartingChild == null) { cancelExpansion(); } else { @@ -263,7 +263,10 @@ public class DragDownHelper implements Gefingerpoken { /** * @return true if the interaction is accepted, false if it should be cancelled */ - boolean onDraggedDown(View startingChild, int dragLengthY); + boolean canDragDown(); + + /** Call when a view has been dragged. */ + void onDraggedDown(View startingChild, int dragLengthY); void onDragDownReset(); /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index ad06e7d06270b..b28cc145dbabe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5499,9 +5499,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.INPUT) private final DragDownCallback mDragDownCallback = new DragDownCallback() { + @Override + public boolean canDragDown() { + return mStatusBarState == StatusBarState.KEYGUARD + && (mController.hasActiveNotifications() || mKeyguardMediaControllorVisible) + || mController.isInLockedDownShade(); + } + /* Only ever called as a consequence of a lockscreen expansion gesture. */ @Override - public boolean onDraggedDown(View startingChild, int dragLengthY) { + public void onDraggedDown(View startingChild, int dragLengthY) { boolean canDragDown = mController.hasActiveNotifications() || mKeyguardMediaControllorVisible; if (mStatusBarState == StatusBarState.KEYGUARD && canDragDown) { @@ -5519,16 +5526,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable row.onExpandedByGesture(true /* drag down is always an open */); } } - - return true; } else if (mController.isInLockedDownShade()) { mStatusbarStateController.setLeaveOpenOnKeyguardHide(true); mStatusBar.dismissKeyguardThenExecute(() -> false /* dismissAction */, null /* cancelRunnable */, false /* afterKeyguardGone */); - return true; - } else { - // abort gesture. - return false; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index ce7b3979c52d8..7776e69d9bed3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -59,10 +59,12 @@ import com.android.systemui.ExpandHelper; import com.android.systemui.Gefingerpoken; import com.android.systemui.R; import com.android.systemui.SwipeHelper; +import com.android.systemui.classifier.Classifier; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.media.KeyguardMediaController; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; @@ -143,6 +145,7 @@ public class NotificationStackScrollLayoutController { private final ZenModeController mZenModeController; private final MetricsLogger mMetricsLogger; private final FalsingCollector mFalsingCollector; + private final FalsingManager mFalsingManager; private final Resources mResources; private final NotificationSwipeHelper.Builder mNotificationSwipeHelperBuilder; private final ScrimController mScrimController; @@ -556,6 +559,7 @@ public class NotificationStackScrollLayoutController { NotificationLockscreenUserManager lockscreenUserManager, MetricsLogger metricsLogger, FalsingCollector falsingCollector, + FalsingManager falsingManager, @Main Resources resources, NotificationSwipeHelper.Builder notificationSwipeHelperBuilder, StatusBar statusBar, @@ -589,6 +593,7 @@ public class NotificationStackScrollLayoutController { mLockscreenUserManager = lockscreenUserManager; mMetricsLogger = metricsLogger; mFalsingCollector = falsingCollector; + mFalsingManager = falsingManager; mResources = resources; mNotificationSwipeHelperBuilder = notificationSwipeHelperBuilder; mStatusBar = statusBar; @@ -1614,6 +1619,9 @@ public class NotificationStackScrollLayoutController { } } if (ev.getActionMasked() == MotionEvent.ACTION_UP) { + // Ensure the falsing manager records the touch. we don't do anything with it + // at the moment. + mFalsingManager.isFalseTouch(Classifier.SHADE_DRAG); mView.setCheckForLeaveBehind(true); } traceJankOnTouchEvent(ev.getActionMasked(), scrollerWantsIt); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 364b532504ff8..610369b3b1ddf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -24,6 +24,7 @@ import static androidx.constraintlayout.widget.ConstraintSet.START; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE; +import static com.android.systemui.classifier.Classifier.QS_COLLAPSE; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; @@ -1450,11 +1451,7 @@ public class NotificationPanelViewController extends PanelViewController { case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: trackMovement(event); - if (mQsTracking) { - flingQsWithCurrentVelocity(y, - event.getActionMasked() == MotionEvent.ACTION_CANCEL); - mQsTracking = false; - } + mQsTracking = false; break; } return false; @@ -1526,10 +1523,17 @@ public class NotificationPanelViewController extends PanelViewController { private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) { float vel = getCurrentQSVelocity(); - final boolean expandsQs = flingExpandsQs(vel); + boolean expandsQs = flingExpandsQs(vel); if (expandsQs) { - logQsSwipeDown(y); + if (mFalsingManager.isUnlockingDisabled() || isFalseTouch(QUICK_SETTINGS)) { + expandsQs = false; + } else { + logQsSwipeDown(y); + } + } else if (vel < 0) { + mFalsingManager.isFalseTouch(QS_COLLAPSE); } + flingSettings(vel, expandsQs && !isCancelMotionEvent ? FLING_EXPAND : FLING_COLLAPSE); } @@ -1545,9 +1549,6 @@ public class NotificationPanelViewController extends PanelViewController { } private boolean flingExpandsQs(float vel) { - if (mFalsingManager.isUnlockingDisabled() || isFalseTouch(QUICK_SETTINGS)) { - return false; - } if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) { return getQsExpansionFraction() > 0.5f; } else { @@ -1556,9 +1557,6 @@ public class NotificationPanelViewController extends PanelViewController { } private boolean isFalseTouch(@Classifier.InteractionType int interactionType) { - if (!mKeyguardAffordanceHelperCallback.needsAntiFalsing()) { - return false; - } if (mFalsingManager.isClassifierEnabled()) { return mFalsingManager.isFalseTouch(interactionType); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 77abe792ee8e1..936e28960f471 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE; import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK; +import static com.android.systemui.classifier.Classifier.GENERIC; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.classifier.Classifier.UNLOCK; @@ -430,9 +431,9 @@ public abstract class PanelViewController { mLockscreenGestureLogger.write(MetricsEvent.ACTION_LS_UNLOCK, heightDp, velocityDp); mLockscreenGestureLogger.log(LockscreenUiEvent.LOCKSCREEN_UNLOCK); } - @Classifier.InteractionType int interactionType = vel > 0 - ? QUICK_SETTINGS : ( - mKeyguardStateController.canDismissLockScreen() + @Classifier.InteractionType int interactionType = vel == 0 ? GENERIC + : vel > 0 ? QUICK_SETTINGS + : (mKeyguardStateController.canDismissLockScreen() ? UNLOCK : BOUNCER_UNLOCK); fling(vel, expand, isFalseTouch(x, y, interactionType)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 7e433e88c60aa..c37ddd91cd8b0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1825,7 +1825,7 @@ public class StatusBar extends SystemUI implements DemoMode, } public boolean isFalsingThresholdNeeded() { - return mStatusBarStateController.getState() == StatusBarState.KEYGUARD; + return true; } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java index 3c4fde8f6106e..895339fb7aaa4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java @@ -43,6 +43,7 @@ import com.android.internal.logging.nano.MetricsProto; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.SysuiTestCase; import com.android.systemui.classifier.FalsingCollectorFake; +import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.media.KeyguardMediaController; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; @@ -160,6 +161,7 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { mNotificationLockscreenUserManager, mMetricsLogger, new FalsingCollectorFake(), + new FalsingManagerFake(), mResources, mNotificationSwipeHelperBuilder, mStatusBar,