summaryrefslogtreecommitdiff
path: root/core/java/android/widget/ScrollView.java
diff options
context:
space:
mode:
authorJohan Rosengren <johan.rosengren@sonyericsson.com>2011-02-21 09:49:45 +0100
committerKenneth Andersson <kenneth.andersson@sonymobile.com>2012-08-23 13:46:14 +0200
commit0dc291eef630cbc3c4479fff8c549567ac980f87 (patch)
treebe631bedc38bee42f442a0007cc8507df9c3fae5 /core/java/android/widget/ScrollView.java
parent9f7fa4c4177c405566445760ec7f4c27e812cd7f (diff)
Protecting more views from (bad) MotionEvents
When handling MotionEvents, the method findPointerIndex can return -1 if the current pointer id can't be translated to a pointer index. Some views are not handling this, which will lead to an out-of- index crash. In 2585e9b there were checks added, this change adds some more. Change-Id: I93ce2420afd83a06b689a1ed35ead7d170cd68f1
Diffstat (limited to 'core/java/android/widget/ScrollView.java')
-rw-r--r--core/java/android/widget/ScrollView.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index ebc54f4527c8..8747dc3dba5f 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.FocusFinder;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -69,6 +70,8 @@ public class ScrollView extends FrameLayout {
static final float MAX_SCROLL_FACTOR = 0.5f;
+ private static final String TAG = "ScrollView";
+
private long mLastScroll;
private final Rect mTempRect = new Rect();
@@ -478,6 +481,12 @@ public class ScrollView extends FrameLayout {
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
+ if (pointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + activePointerId
+ + " in onInterceptTouchEvent");
+ break;
+ }
+
final int y = (int) ev.getY(pointerIndex);
final int yDiff = Math.abs(y - mLastMotionY);
if (yDiff > mTouchSlop) {
@@ -585,6 +594,11 @@ public class ScrollView extends FrameLayout {
}
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
+ if (activePointerIndex == -1) {
+ Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
+ break;
+ }
+
final int y = (int) ev.getY(activePointerIndex);
int deltaY = mLastMotionY - y;
if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {