From 9d09824a66e3a9785f3f05929bc9139da108efe4 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Sun, 7 Oct 2012 23:27:30 -0400 Subject: 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 --- .../systemui/statusbar/phone/PanelView.java | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 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 0c9683d15387..b3cf85435a86 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -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); + + yVel = mVelocityTracker.getYVelocity(); + negative = yVel < 0; - float vel = (float)Math.hypot(yVel, xVel); - if (vel > mFlingGestureMaxOutputVelocityPx) { - vel = mFlingGestureMaxOutputVelocityPx; + 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; -- cgit v1.2.3-59-g8ed1b