From 86fb6220fa27b35c2621eda06b2b9025f672f994 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 30 Nov 2021 12:14:02 -0500 Subject: [PATCH] Don't send lock icon touches to NotifShade If the lock icon affordance enters the device, we don't want the shade to expand after device entry. Test: manual Fixes: 208364482 Change-Id: If2d5b5296f7820b099e4315f9586632993617955 --- .../keyguard/LockIconViewController.java | 38 ++++++++++++------- ...NotificationShadeWindowViewController.java | 5 +++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index 88476398e09d1..163392314cfc3 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -661,26 +661,38 @@ public class LockIconViewController extends ViewController impleme * @return whether to intercept the touch event */ public boolean onTouchEvent(MotionEvent event, Runnable onGestureDetectedRunnable) { - if (mSensorTouchLocation.contains((int) event.getX(), (int) event.getY()) - && (mView.getVisibility() == View.VISIBLE - || (mAodFp != null && mAodFp.getVisibility() == View.VISIBLE))) { + if (onInterceptTouchEvent(event)) { mOnGestureDetectedRunnable = onGestureDetectedRunnable; mGestureDetector.onTouchEvent(event); - } - - // we continue to intercept all following touches until we see MotionEvent.ACTION_CANCEL UP - // or MotionEvent.ACTION_UP. this is to avoid passing the touch to NPV - // after the lock icon disappears on device entry - if (mDownDetected) { - if (event.getAction() == MotionEvent.ACTION_CANCEL - || event.getAction() == MotionEvent.ACTION_UP) { - mDownDetected = false; - } return true; } + + mDownDetected = false; return false; } + /** + * Intercepts the touch if the onDown event and current event are within this lock icon view's + * bounds. + */ + public boolean onInterceptTouchEvent(MotionEvent event) { + if (!inLockIconArea(event) || !isClickable()) { + return false; + } + + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { + return true; + } + + return mDownDetected; + } + + private boolean inLockIconArea(MotionEvent event) { + return mSensorTouchLocation.contains((int) event.getX(), (int) event.getY()) + && (mView.getVisibility() == View.VISIBLE + || (mAodFp != null && mAodFp.getVisibility() == View.VISIBLE)); + } + private boolean isClickable() { return mUdfpsSupported || mShowUnlockIcon; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java index 01587f7fe98c7..55f14500f8fc8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java @@ -338,6 +338,11 @@ public class NotificationShadeWindowViewController { return true; } + if (mLockIconViewController.onInterceptTouchEvent(ev)) { + // immediately return true; don't send the touch to the drag down helper + return true; + } + boolean intercept = false; if (mNotificationPanelViewController.isFullyExpanded() && mDragDownHelper.isDragDownEnabled()