summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-11-11 11:55:52 -0800
committerYorke Lee <yorkelee@google.com>2014-11-11 13:16:54 -0800
commit35b889008044d7a47684e1043465124fbf65621d (patch)
tree2e0a9b217453e479accae7576c9d76635c0ab380 /src
parent612f818e54a6652982b2d877b57e4024bb6f7b68 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/widget/ViewDragHelper.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/com/android/dialer/widget/ViewDragHelper.java b/src/com/android/dialer/widget/ViewDragHelper.java
index c0bc2ce29..fe3ab8230 100644
--- a/src/com/android/dialer/widget/ViewDragHelper.java
+++ b/src/com/android/dialer/widget/ViewDragHelper.java
@@ -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]);