From d17786fcd21e53b81e4d4e924adc8becdfa46ec2 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 16 Nov 2011 15:53:03 -0800 Subject: [PATCH] Fix IndexOutOfBoundsException in monkey test Bug: 5627027 Change-Id: I341cfa5c3d553a1c819d8455936b40a40ad30e87 --- .../internal/PointerTrackerQueue.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java index 55175e046..08e7a7a4e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java @@ -21,13 +21,13 @@ import com.android.inputmethod.keyboard.PointerTracker; import java.util.LinkedList; public class PointerTrackerQueue { - private LinkedList mQueue = new LinkedList(); + private final LinkedList mQueue = new LinkedList(); - public void add(PointerTracker tracker) { + public synchronized void add(PointerTracker tracker) { mQueue.add(tracker); } - public void releaseAllPointersOlderThan(PointerTracker tracker, long eventTime) { + public synchronized void releaseAllPointersOlderThan(PointerTracker tracker, long eventTime) { if (mQueue.lastIndexOf(tracker) < 0) { return; } @@ -47,25 +47,28 @@ public class PointerTrackerQueue { releaseAllPointersExcept(null, eventTime); } - public void releaseAllPointersExcept(PointerTracker tracker, long eventTime) { + public synchronized void releaseAllPointersExcept(PointerTracker tracker, long eventTime) { for (PointerTracker t : mQueue) { - if (t == tracker) + if (t == tracker) { continue; + } t.onPhantomUpEvent(t.getLastX(), t.getLastY(), eventTime); } mQueue.clear(); - if (tracker != null) + if (tracker != null) { mQueue.add(tracker); + } } - public void remove(PointerTracker tracker) { + public synchronized void remove(PointerTracker tracker) { mQueue.remove(tracker); } - public boolean isAnyInSlidingKeyInput() { + public synchronized boolean isAnyInSlidingKeyInput() { for (final PointerTracker tracker : mQueue) { - if (tracker.isInSlidingKeyInput()) + if (tracker.isInSlidingKeyInput()) { return true; + } } return false; }