am 14950497: am 1e256f58: Merge "Protect simultaneously modifying gesture preview data"
* commit '14950497280f15b6d1de9e6c5d159ce46e27180b': Protect simultaneously modifying gesture preview datamain
commit
8ea774ebf2
|
@ -37,6 +37,7 @@ import com.android.inputmethod.latin.ResizableIntArray;
|
|||
final class GesturePreviewTrail {
|
||||
private static final int DEFAULT_CAPACITY = GestureStrokeWithPreviewPoints.PREVIEW_CAPACITY;
|
||||
|
||||
// These three {@link ResizableIntArray}s should be synchronized by {@link #mEventTimes}.
|
||||
private final ResizableIntArray mXCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||
private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||
private final ResizableIntArray mEventTimes = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||
|
@ -90,6 +91,12 @@ final class GesturePreviewTrail {
|
|||
}
|
||||
|
||||
public void addStroke(final GestureStrokeWithPreviewPoints stroke, final long downTime) {
|
||||
synchronized (mEventTimes) {
|
||||
addStrokeLocked(stroke, downTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke, final long downTime) {
|
||||
final int trailSize = mEventTimes.getLength();
|
||||
stroke.appendPreviewStroke(mEventTimes, mXCoordinates, mYCoordinates);
|
||||
if (mEventTimes.getLength() == trailSize) {
|
||||
|
@ -169,6 +176,13 @@ final class GesturePreviewTrail {
|
|||
*/
|
||||
public boolean drawGestureTrail(final Canvas canvas, final Paint paint,
|
||||
final Rect outBoundsRect, final Params params) {
|
||||
synchronized (mEventTimes) {
|
||||
return drawGestureTrailLocked(canvas, paint, outBoundsRect, params);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean drawGestureTrailLocked(final Canvas canvas, final Paint paint,
|
||||
final Rect outBoundsRect, final Params params) {
|
||||
// Initialize bounds rectangle.
|
||||
outBoundsRect.setEmpty();
|
||||
final int trailSize = mEventTimes.getLength();
|
||||
|
|
Loading…
Reference in New Issue