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

Commit 35b88900 authored by Yorke Lee's avatar Yorke Lee
Browse files

Fix IOOB exception in ViewDragHelper

If findPointerIndex returns -1, ignore the motion event. The
equivalent fix is done for other handlers of motion events as well.

Bug: 18186775

Change-Id: Ia7548335eeb84310510260381a8bcedf6556aa40
parent 612f818e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -1176,7 +1177,12 @@ public class ViewDragHelper {

            case MotionEvent.ACTION_MOVE: {
                if (mDragState == STATE_DRAGGING) {
                    final int index = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
                    int index = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
                    if (index < 0) {
                        Log.e(TAG, "Pointer index for id " + mActivePointerId + " not found."
                                + " Skipping MotionEvent");
                        return;
                    }
                    final float x = MotionEventCompat.getX(ev, index);
                    final float y = MotionEventCompat.getY(ev, index);
                    final int idx = (int) (x - mLastMotionX[mActivePointerId]);