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

Commit c5171f78 authored by Arnab Sen's avatar Arnab Sen
Browse files

Fix NullPointerException in GestureDetector

NPE can be thrown from GestureDetector on GestureDetector#cancel which
can crash an app as VelocityTracker object is not checked for null
before calling VelocityTracker#recycle.
This change fixes the issue by checking for null VelocityTracker before
calling VelocityTracker#recycle on GestureDetector#cancel.

Test: Precautionary fix to prevent crashes, no test was run

Change-Id: I805ac4a19fbd766a9d0f17732b158f1d1e61aae6
parent 62434fd9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -839,8 +839,10 @@ public class GestureDetector {
        mHandler.removeMessages(SHOW_PRESS);
        mHandler.removeMessages(LONG_PRESS);
        mHandler.removeMessages(TAP);
        if (mVelocityTracker != null) {
            mVelocityTracker.recycle();
            mVelocityTracker = null;
        }
        mIsDoubleTapping = false;
        mStillDown = false;
        mAlwaysInTapRegion = false;