Skip to content

Commit e451552

Browse files
dsandlerAndroid Git Automerger
authored andcommitted
am 5fd8cd3: am bb1c1d3: am de8e3b1: Merge "Fix NPE if pulling down QS quickly on very first boot." into jb-mr1-dev
* commit '5fd8cd3e1981ae248ad609a17f88df4b4fd4a159': Fix NPE if pulling down QS quickly on very first boot.
2 parents 47c9118 + 5fd8cd3 commit e451552

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)