summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2015-03-16 18:00:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-16 18:01:00 +0000
commitb60a658edbfae486a4b9975da3f701ff5a2d31be (patch)
treeefa4c9003fa78513687c40d691b2c64b0a836155 /packages
parent08067d98295303cf9c8235ab27b3e6e8038f084c (diff)
parent547a06b50fa97cd079851f80d0d5aa5297cbb040 (diff)
downloadframeworks_base-b60a658edbfae486a4b9975da3f701ff5a2d31be.zip
frameworks_base-b60a658edbfae486a4b9975da3f701ff5a2d31be.tar.gz
frameworks_base-b60a658edbfae486a4b9975da3f701ff5a2d31be.tar.bz2
Merge "Added more anti-falsing logic"
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java109
1 files changed, 69 insertions, 40 deletions
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 47034e2..4bbf690 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -73,6 +73,7 @@ public abstract class PanelView extends FrameLayout {
private boolean mTouchAboveFalsingThreshold;
private int mUnlockFalsingThreshold;
private boolean mTouchStartedInEmptyArea;
+ private boolean mMotionAborted;
private ValueAnimator mHeightAnimator;
private ObjectAnimator mPeekAnimator;
@@ -208,7 +209,8 @@ public abstract class PanelView extends FrameLayout {
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (mInstantExpanding || mTouchDisabled) {
+ if (mInstantExpanding || mTouchDisabled
+ || (mMotionAborted && event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
return false;
}
@@ -226,8 +228,8 @@ public abstract class PanelView extends FrameLayout {
pointerIndex = 0;
mTrackingPointer = event.getPointerId(pointerIndex);
}
- final float y = event.getY(pointerIndex);
final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mGestureWaitForTouchSlop = mExpandedHeight == 0f;
@@ -244,6 +246,7 @@ public abstract class PanelView extends FrameLayout {
mPanelClosedOnDown = mExpandedHeight == 0.0f;
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
+ mMotionAborted = false;
mPeekTouching = mPanelClosedOnDown;
mTouchAboveFalsingThreshold = false;
if (mVelocityTracker == null) {
@@ -276,7 +279,13 @@ public abstract class PanelView extends FrameLayout {
mInitialTouchX = newX;
}
break;
-
+ case MotionEvent.ACTION_POINTER_DOWN:
+ if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
+ mMotionAborted = true;
+ endMotionEvent(event, x, y, true /* forceCancel */);
+ return false;
+ }
+ break;
case MotionEvent.ACTION_MOVE:
float h = y - mInitialTouchY;
@@ -318,26 +327,35 @@ public abstract class PanelView extends FrameLayout {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- mTrackingPointer = -1;
trackMovement(event);
- if ((mTracking && mTouchSlopExceeded)
- || Math.abs(x - mInitialTouchX) > mTouchSlop
- || Math.abs(y - mInitialTouchY) > mTouchSlop
- || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
- float vel = 0f;
- float vectorVel = 0f;
- if (mVelocityTracker != null) {
- mVelocityTracker.computeCurrentVelocity(1000);
- vel = mVelocityTracker.getYVelocity();
- vectorVel = (float) Math.hypot(
- mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
- }
- boolean expand = flingExpands(vel, vectorVel)
- || event.getActionMasked() == MotionEvent.ACTION_CANCEL;
- onTrackingStopped(expand);
- DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
- mStatusBar.isFalsingThresholdNeeded(),
- mStatusBar.isScreenOnComingFromTouch());
+ endMotionEvent(event, x, y, false /* forceCancel */);
+ break;
+ }
+ return !waitForTouchSlop || mTracking;
+ }
+
+ private void endMotionEvent(MotionEvent event, float x, float y, boolean forceCancel) {
+ mTrackingPointer = -1;
+ if ((mTracking && mTouchSlopExceeded)
+ || Math.abs(x - mInitialTouchX) > mTouchSlop
+ || Math.abs(y - mInitialTouchY) > mTouchSlop
+ || event.getActionMasked() == MotionEvent.ACTION_CANCEL
+ || forceCancel) {
+ float vel = 0f;
+ float vectorVel = 0f;
+ if (mVelocityTracker != null) {
+ mVelocityTracker.computeCurrentVelocity(1000);
+ vel = mVelocityTracker.getYVelocity();
+ vectorVel = (float) Math.hypot(
+ mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
+ }
+ boolean expand = flingExpands(vel, vectorVel)
+ || event.getActionMasked() == MotionEvent.ACTION_CANCEL
+ || forceCancel;
+ onTrackingStopped(expand);
+ DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
+ mStatusBar.isFalsingThresholdNeeded(),
+ mStatusBar.isScreenOnComingFromTouch());
// Log collapse gesture if on lock screen.
if (!expand && mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
float displayDensity = mStatusBar.getDisplayDensity();
@@ -347,24 +365,21 @@ public abstract class PanelView extends FrameLayout {
EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_UP_UNLOCK,
heightDp, velocityDp);
}
- fling(vel, expand);
- mUpdateFlingOnLayout = expand && mPanelClosedOnDown && !mHasLayoutedSinceDown;
- if (mUpdateFlingOnLayout) {
- mUpdateFlingVelocity = vel;
- }
- } else {
- boolean expands = onEmptySpaceClick(mInitialTouchX);
- onTrackingStopped(expands);
- }
+ fling(vel, expand);
+ mUpdateFlingOnLayout = expand && mPanelClosedOnDown && !mHasLayoutedSinceDown;
+ if (mUpdateFlingOnLayout) {
+ mUpdateFlingVelocity = vel;
+ }
+ } else {
+ boolean expands = onEmptySpaceClick(mInitialTouchX);
+ onTrackingStopped(expands);
+ }
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
- mPeekTouching = false;
- break;
+ if (mVelocityTracker != null) {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
}
- return !waitForTouchSlop || mTracking;
+ mPeekTouching = false;
}
private int getFalsingThreshold() {
@@ -389,7 +404,8 @@ public abstract class PanelView extends FrameLayout {
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- if (mInstantExpanding) {
+ if (mInstantExpanding
+ || (mMotionAborted && event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
return false;
}
@@ -425,6 +441,7 @@ public abstract class PanelView extends FrameLayout {
mTouchStartedInEmptyArea = !isInContentBounds(x, y);
mTouchSlopExceeded = false;
mJustPeeked = false;
+ mMotionAborted = false;
mPanelClosedOnDown = mExpandedHeight == 0.0f;
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
@@ -442,7 +459,15 @@ public abstract class PanelView extends FrameLayout {
mInitialTouchY = event.getY(newIndex);
}
break;
-
+ case MotionEvent.ACTION_POINTER_DOWN:
+ if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
+ mMotionAborted = true;
+ if (mVelocityTracker != null) {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
+ }
+ break;
case MotionEvent.ACTION_MOVE:
final float h = y - mInitialTouchY;
trackMovement(event);
@@ -461,6 +486,10 @@ public abstract class PanelView extends FrameLayout {
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
+ if (mVelocityTracker != null) {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
break;
}
return false;