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/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 {