summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar/phone
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2013-03-26 16:23:37 +0200
committerMichael Bestas <mikeioannina@gmail.com>2013-03-26 16:24:35 +0200
commita2e0cc09d9f081f8f5750937efb93637e05c024c (patch)
treecd605237eddab9773b8225157eb29adeb71a8c05 /packages/SystemUI/src/com/android/systemui/statusbar/phone
parentda062dc61ce6285caad889a0b7abe3232cc03790 (diff)
downloadframeworks_base-a2e0cc09d9f081f8f5750937efb93637e05c024c.zip
frameworks_base-a2e0cc09d9f081f8f5750937efb93637e05c024c.tar.gz
frameworks_base-a2e0cc09d9f081f8f5750937efb93637e05c024c.tar.bz2
FlingTracker can divide by zero and hang StatusBar in an infinite loop
if 2 events have the same timestamp then FlingTracker in PanelView will divide by zero causing NaNs. the bug is usually triggered by rapid StatusBar up/down dragging activity and updateCarrierLabelVisibility can then loop indefinitely looking at NaNs. the user visible symptom is that StatusBar refuses to pull down and is burning cpu time. Signed-off-by: Michael Bestas <mikeioannina@gmail.com> Change-Id: I0791c6bea953bf03346185fc6aaf44aaea79aace
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/phone')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java12
1 files changed, 10 insertions, 2 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 5d9c7bc..0c7a5c5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -114,6 +114,7 @@ public class PanelView extends FrameLayout {
mVX = mVY = 0;
MotionEventCopy last = null;
int i = 0;
+ int j = 0;
float totalweight = 0f;
float weight = 10f;
for (final Iterator<MotionEventCopy> iter = mEventBuf.descendingIterator();
@@ -121,6 +122,10 @@ public class PanelView extends FrameLayout {
final MotionEventCopy event = iter.next();
if (last != null) {
final float dt = (float) (event.t - last.t) / timebase;
+ if (dt == 0) {
+ last = event;
+ continue;
+ }
final float dx = (event.x - last.x);
final float dy = (event.y - last.y);
if (FlingTracker.DEBUG) {
@@ -135,12 +140,15 @@ public class PanelView extends FrameLayout {
mVY += weight * dy / dt;
totalweight += weight;
weight *= DECAY;
+ j++;
}
last = event;
i++;
}
- mVX /= totalweight;
- mVY /= totalweight;
+ if (j != 0) {
+ mVX /= totalweight;
+ mVY /= totalweight;
+ }
if (FlingTracker.DEBUG) {
Slog.v("FlingTracker", "computed: vx=" + mVX + " vy=" + mVY);