Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0ea33a4 authored by Daniel Hillenbrand's avatar Daniel Hillenbrand Committed by Gerrit Code Review
Browse files

Merge "FlingTracker can divide by zero and hang StatusBar in an infinite loop" into cm-10.1

parents dad194eb a2e0cc09
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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++;
            }
            if (j != 0) {
                mVX /= totalweight;
                mVY /= totalweight;
            }

            if (FlingTracker.DEBUG) {
                Slog.v("FlingTracker", "computed: vx=" + mVX + " vy=" + mVY);