Skip to content

Commit 9d09824

Browse files
committed
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
1 parent b341959 commit 9d09824

File tree

1 file changed

+23
-16
lines changed
  • packages/SystemUI/src/com/android/systemui/statusbar/phone

1 file changed

+23
-16
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,32 @@ public boolean onTouch(View v, MotionEvent event) {
281281
mHandleView.setPressed(false);
282282
mBar.onTrackingStopped(PanelView.this);
283283
trackMovement(event);
284-
mVelocityTracker.computeCurrentVelocity(1000);
285284

286-
float yVel = mVelocityTracker.getYVelocity();
287-
boolean negative = yVel < 0;
285+
float vel = 0, yVel = 0, xVel = 0;
286+
boolean negative = false;
288287

289-
float xVel = mVelocityTracker.getXVelocity();
290-
if (xVel < 0) {
291-
xVel = -xVel;
292-
}
293-
if (xVel > mFlingGestureMaxXVelocityPx) {
294-
xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
295-
}
288+
if (mVelocityTracker != null) {
289+
// the velocitytracker might be null if we got a bad input stream
290+
mVelocityTracker.computeCurrentVelocity(1000);
291+
292+
yVel = mVelocityTracker.getYVelocity();
293+
negative = yVel < 0;
296294

297-
float vel = (float)Math.hypot(yVel, xVel);
298-
if (vel > mFlingGestureMaxOutputVelocityPx) {
299-
vel = mFlingGestureMaxOutputVelocityPx;
295+
xVel = mVelocityTracker.getXVelocity();
296+
if (xVel < 0) {
297+
xVel = -xVel;
298+
}
299+
if (xVel > mFlingGestureMaxXVelocityPx) {
300+
xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
301+
}
302+
303+
vel = (float)Math.hypot(yVel, xVel);
304+
if (vel > mFlingGestureMaxOutputVelocityPx) {
305+
vel = mFlingGestureMaxOutputVelocityPx;
306+
}
307+
308+
mVelocityTracker.recycle();
309+
mVelocityTracker = null;
300310
}
301311

302312
// if you've barely moved your finger, we treat the velocity as 0
@@ -321,9 +331,6 @@ public boolean onTouch(View v, MotionEvent event) {
321331

322332
fling(vel, true);
323333

324-
mVelocityTracker.recycle();
325-
mVelocityTracker = null;
326-
327334
break;
328335
}
329336
return true;

0 commit comments

Comments
 (0)