diff options
| author | 2011-06-27 12:00:54 -0700 | |
|---|---|---|
| committer | 2011-06-27 12:06:17 -0700 | |
| commit | 51cccf0845b36539d42503495f0689d487712b3a (patch) | |
| tree | 217a0059bdde4e2010abbd0d470cb33c045b9458 | |
| parent | c18e7e73158f794064fed5017c6c1c9a288673bd (diff) | |
ArrayIndexOutOfBounds exception in TouchExplorer.
1. The explorer was injecting up/down touch events to
click with the id of the last pointer that went up
but the prototype i.e. last touch explore event may
not contain this pointer. Since we click on the last
touch explored location then using the action pointer
index of that event is the right approach.
bug:4551506
Change-Id: I73428b09dc014417096a52e667f58768a2871dc8
| -rw-r--r-- | services/java/com/android/server/accessibility/TouchExplorer.java | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java index aab189a68cda..1af701577f59 100644 --- a/services/java/com/android/server/accessibility/TouchExplorer.java +++ b/services/java/com/android/server/accessibility/TouchExplorer.java @@ -26,7 +26,6 @@ import android.content.Context; import android.os.Handler; import android.os.SystemClock; import android.util.Slog; -import android.util.SparseArray; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.WindowManagerPolicy; @@ -73,15 +72,6 @@ public class TouchExplorer implements Explorer { private static final int STATE_DRAGGING = 0x00000002; private static final int STATE_DELEGATING = 0x00000004; - // Human readable symbolic names for the states of the explorer. - private static final SparseArray<String> sStateSymbolicNames = new SparseArray<String>(); - static { - SparseArray<String> symbolicNames = sStateSymbolicNames; - symbolicNames.append(STATE_TOUCH_EXPLORING, "STATE_TOUCH_EXPLORING"); - symbolicNames.append(STATE_DRAGGING, "STATE_DRAGING"); - symbolicNames.append(STATE_DELEGATING, "STATE_DELEGATING"); - } - // Invalid pointer ID. private static final int INVALID_POINTER_ID = -1; @@ -189,7 +179,7 @@ public class TouchExplorer implements Explorer { if (DEBUG) { Slog.d(LOG_TAG_RECEIVED, "Received event: " + event + ", policyFlags=0x" + Integer.toHexString(policyFlags)); - Slog.d(LOG_TAG_STATE, sStateSymbolicNames.get(mCurrentState)); + Slog.d(LOG_TAG_STATE, getStateSymbolicName(mCurrentState)); } // Keep track of the pointers's state. @@ -708,8 +698,7 @@ public class TouchExplorer implements Explorer { private void sendActionDownAndUp(MotionEvent prototype, int policyFlags) { final PointerProperties[] pointerProperties = mTempPointerProperties; final PointerCoords[] pointerCoords = mTempPointerCoords; - final int pointerId = mPointerTracker.getLastReceivedUpPointerId(); - final int pointerIndex = prototype.findPointerIndex(pointerId); + final int pointerIndex = prototype.getActionIndex(); // Send down. prototype.getPointerProperties(pointerIndex, pointerProperties[0]); @@ -884,6 +873,25 @@ public class TouchExplorer implements Explorer { } /** + * Gets the symbolic name of a state. + * + * @param state A state. + * @return The state symbolic name. + */ + private static String getStateSymbolicName(int state) { + switch (state) { + case STATE_TOUCH_EXPLORING: + return "STATE_TOUCH_EXPLORING"; + case STATE_DRAGGING: + return "STATE_DRAGGING"; + case STATE_DELEGATING: + return "STATE_DELEGATING"; + default: + throw new IllegalArgumentException("Unknown state: " + state); + } + } + + /** * Helper class for tracking pointers and more specifically which of * them are currently down, which are active, and which are delivered * to the view hierarchy. The enclosing {@link TouchExplorer} uses the |