From 7c6dd3d568c028d197322ad148d109c745ec53f8 Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Tue, 7 Jul 2020 13:17:45 -0400 Subject: Collapse shade on ACTION_CANCEL (sometimes) As of ag/11546928, the framework emits an ACTION_CANCEL when the proximity sensor turns off the screen, not an ACTION_UP. Previously, we always expanded the shade in response to an ACTION_CANCEL. However, after this change, this caused Dialer users to end up with an expanded shade after putting the phone to their face, making it easy to face-dial their notifications. This CL changes the behavior to put the shade back to where it was when the gesture started -- either expanded or closed. Fixes: 155362798 Test: manual Change-Id: I2d11d9f03bfe1e905028a640e2eb871d32e37248 --- .../statusbar/phone/PanelViewController.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 732f25f90eb5..e942d85790c1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -371,12 +371,26 @@ public abstract class PanelViewController { float vectorVel = (float) Math.hypot( mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); - boolean expand = flingExpands(vel, vectorVel, x, y) - || event.getActionMasked() == MotionEvent.ACTION_CANCEL || forceCancel; + final boolean onKeyguard = + mStatusBarStateController.getState() == StatusBarState.KEYGUARD; + + final boolean expand; + if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || forceCancel) { + // If we get a cancel, put the shade back to the state it was in when the gesture + // started + if (onKeyguard) { + expand = true; + } else { + expand = !mPanelClosedOnDown; + } + } else { + expand = flingExpands(vel, vectorVel, x, y); + } + mDozeLog.traceFling(expand, mTouchAboveFalsingThreshold, mStatusBar.isFalsingThresholdNeeded(), mStatusBar.isWakeUpComingFromTouch()); // Log collapse gesture if on lock screen. - if (!expand && mStatusBarStateController.getState() == StatusBarState.KEYGUARD) { + if (!expand && onKeyguard) { float displayDensity = mStatusBar.getDisplayDensity(); int heightDp = (int) Math.abs((y - mInitialTouchY) / displayDensity); int velocityDp = (int) Math.abs(vel / displayDensity); -- cgit v1.2.3-59-g8ed1b