Fix NPE if pulling down QS quickly on very first boot.

The cling interception code can interfere with the touch
stream to the point that PanelView might get an ACTION_UP or
_CANCEL without a corresponding ACTION_DOWN, causing
problems.

Bug: 7301742
Change-Id: Idd5074c2544b3238517655ab3c068966bae9f912
This commit is contained in:
Daniel Sandler
2012-10-07 23:27:30 -04:00
parent b3419595c7
commit 9d09824a66

View File

@@ -281,22 +281,32 @@ public class PanelView extends FrameLayout {
mHandleView.setPressed(false);
mBar.onTrackingStopped(PanelView.this);
trackMovement(event);
mVelocityTracker.computeCurrentVelocity(1000);
float yVel = mVelocityTracker.getYVelocity();
boolean negative = yVel < 0;
float vel = 0, yVel = 0, xVel = 0;
boolean negative = false;
float xVel = mVelocityTracker.getXVelocity();
if (xVel < 0) {
xVel = -xVel;
}
if (xVel > mFlingGestureMaxXVelocityPx) {
xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
}
if (mVelocityTracker != null) {
// the velocitytracker might be null if we got a bad input stream
mVelocityTracker.computeCurrentVelocity(1000);
float vel = (float)Math.hypot(yVel, xVel);
if (vel > mFlingGestureMaxOutputVelocityPx) {
vel = mFlingGestureMaxOutputVelocityPx;
yVel = mVelocityTracker.getYVelocity();
negative = yVel < 0;
xVel = mVelocityTracker.getXVelocity();
if (xVel < 0) {
xVel = -xVel;
}
if (xVel > mFlingGestureMaxXVelocityPx) {
xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
}
vel = (float)Math.hypot(yVel, xVel);
if (vel > mFlingGestureMaxOutputVelocityPx) {
vel = mFlingGestureMaxOutputVelocityPx;
}
mVelocityTracker.recycle();
mVelocityTracker = null;
}
// if you've barely moved your finger, we treat the velocity as 0
@@ -321,9 +331,6 @@ public class PanelView extends FrameLayout {
fling(vel, true);
mVelocityTracker.recycle();
mVelocityTracker = null;
break;
}
return true;