Added anti-falsing logic to the keyguard.
Newly enforcing a threshold for the following cases:
Unlocking, Dismissing Notifications, Swiping Down Quick settings.
Also increased the affordance threshold slightly.
Bug: 15433087
Change-Id: I723346dedf9ae0e3f8b103182992ab572fc394b9
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 387abc3..d3c3f56 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -160,6 +160,8 @@
private boolean mQsScrimEnabled = true;
private boolean mLastAnnouncementWasQuickSettings;
+ private boolean mQsTouchAboveFalsingThreshold;
+ private int mQsFalsingThreshold;
public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -230,6 +232,8 @@
mClockPositionAlgorithm.loadDimens(getResources());
mNotificationScrimWaitDistance =
getResources().getDimensionPixelSize(R.dimen.notification_scrim_wait_distance);
+ mQsFalsingThreshold = getResources().getDimensionPixelSize(
+ R.dimen.qs_falsing_threshold);
}
public void updateResources() {
@@ -526,6 +530,7 @@
private void resetDownStates(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mOnlyAffordanceInThisMotion = false;
+ mQsTouchAboveFalsingThreshold = mQsFullyExpanded;
}
}
@@ -546,6 +551,9 @@
}
private boolean flingExpandsQs(float vel) {
+ if (!mQsTouchAboveFalsingThreshold && mStatusBarState == StatusBarState.KEYGUARD) {
+ return false;
+ }
if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
return getQsExpansionFraction() > 0.5f;
} else {
@@ -690,6 +698,9 @@
case MotionEvent.ACTION_MOVE:
final float h = y - mInitialTouchY;
setQsExpansion(h + mInitialHeightOnTouch);
+ if (h >= mQsFalsingThreshold) {
+ mQsTouchAboveFalsingThreshold = true;
+ }
trackMovement(event);
break;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index b175fd5..e818d23 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -68,6 +68,8 @@
protected boolean mHintAnimationRunning;
private boolean mOverExpandedBeforeFling;
private float mOriginalIndicationY;
+ private boolean mTouchAboveFalsingThreshold;
+ private int mUnlockFalsingThreshold;
private ValueAnimator mHeightAnimator;
private ObjectAnimator mPeekAnimator;
@@ -183,6 +185,7 @@
mTouchSlop = configuration.getScaledTouchSlop();
mHintDistance = res.getDimension(R.dimen.hint_move_distance);
mEdgeTapAreaWidth = res.getDimensionPixelSize(R.dimen.edge_tap_area_width);
+ mUnlockFalsingThreshold = res.getDimensionPixelSize(R.dimen.unlock_falsing_threshold);
}
private void trackMovement(MotionEvent event) {
@@ -234,6 +237,7 @@
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
mPeekTouching = mPanelClosedOnDown;
+ mTouchAboveFalsingThreshold = false;
if (mVelocityTracker == null) {
initVelocityTracker();
}
@@ -298,6 +302,9 @@
}
mJustPeeked = false;
}
+ if (-h >= mUnlockFalsingThreshold) {
+ mTouchAboveFalsingThreshold = true;
+ }
if (!mJustPeeked && (!waitForTouchSlop || mTracking) && !isTrackingBlocked()) {
setExpandedHeightInternal(newHeight);
}
@@ -399,6 +406,7 @@
mPanelClosedOnDown = mExpandedHeight == 0.0f;
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
+ mTouchAboveFalsingThreshold = false;
initVelocityTracker();
trackMovement(event);
break;
@@ -471,6 +479,9 @@
* @return whether a fling should expands the panel; contracts otherwise
*/
protected boolean flingExpands(float vel, float vectorVel) {
+ if (!mTouchAboveFalsingThreshold && mStatusBar.isFalsingThresholdNeeded()) {
+ return true;
+ }
if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
return getExpandedFraction() > 0.5f;
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 620d3ec..21dc27e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -686,6 +686,7 @@
mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById(
R.id.notification_stack_scroller);
mStackScroller.setLongPressListener(getNotificationLongClicker());
+ mStackScroller.setPhoneStatusBar(this);
mKeyguardIconOverflowContainer =
(NotificationOverflowContainer) LayoutInflater.from(mContext).inflate(
@@ -2053,6 +2054,12 @@
return mNotificationPanel.isQsExpanded();
}
+ public boolean isFalsingThresholdNeeded() {
+ boolean onKeyguard = getBarState() == StatusBarState.KEYGUARD;
+ boolean isMethodInSecure = mUnlockMethodCache.isMethodInsecure();
+ return onKeyguard && isMethodInSecure;
+ }
+
@Override // NotificationData.Environment
public String getCurrentMediaNotificationKey() {
return mMediaNotificationKey;