Fix for bug 2502886 - stupid monkeys.

Plugged a possible edge case with ScrollView/HorizontalScrollView that
could cause this error.

Change-Id: I509004189b9f5e536d6213c9fdfff598d9f958ca
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index 702ce0a..0bbf7b8 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -410,7 +410,13 @@
                 * Locally do absolute value. mLastMotionX is set to the x value
                 * of the down event.
                 */
-                final int pointerIndex = ev.findPointerIndex(mActivePointerId);
+                final int activePointerId = mActivePointerId;
+                if (activePointerId == INVALID_POINTER) {
+                    // If we don't have a valid id, the touch down wasn't on content.
+                    break;
+                }
+
+                final int pointerIndex = ev.findPointerIndex(activePointerId);
                 final float x = ev.getX(pointerIndex);
                 final int xDiff = (int) Math.abs(x - mLastMotionX);
                 if (xDiff > mTouchSlop) {
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index f009432..3cf2af2 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -408,7 +408,13 @@
                 * Locally do absolute value. mLastMotionY is set to the y value
                 * of the down event.
                 */
-                final int pointerIndex = ev.findPointerIndex(mActivePointerId);
+                final int activePointerId = mActivePointerId;
+                if (activePointerId == INVALID_POINTER) {
+                    // If we don't have a valid id, the touch down wasn't on content.
+                    break;
+                }
+
+                final int pointerIndex = ev.findPointerIndex(activePointerId);
                 final float y = ev.getY(pointerIndex);
                 final int yDiff = (int) Math.abs(y - mLastMotionY);
                 if (yDiff > mTouchSlop) {