Skip to content

Commit 2cee686

Browse files
committed
Fixing off by one error in the ScreenMagnifier.
Change-Id: Ia0ccfb6b354b7a18633e7cf26647c6436ebf5c08
1 parent 970683c commit 2cee686

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

services/java/com/android/server/accessibility/ScreenMagnifier.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags
286286
private PointerCoords[] getTempPointerCoordsWithMinSize(int size) {
287287
final int oldSize = (mTempPointerCoords != null) ? mTempPointerCoords.length : 0;
288288
if (oldSize < size) {
289+
PointerCoords[] oldTempPointerCoords = mTempPointerCoords;
289290
mTempPointerCoords = new PointerCoords[size];
291+
if (oldTempPointerCoords != null) {
292+
System.arraycopy(oldTempPointerCoords, 0, mTempPointerCoords, 0, oldSize);
293+
}
290294
}
291295
for (int i = oldSize; i < size; i++) {
292296
mTempPointerCoords[i] = new PointerCoords();
@@ -297,7 +301,11 @@ private PointerCoords[] getTempPointerCoordsWithMinSize(int size) {
297301
private PointerProperties[] getTempPointerPropertiesWithMinSize(int size) {
298302
final int oldSize = (mTempPointerProperties != null) ? mTempPointerProperties.length : 0;
299303
if (oldSize < size) {
304+
PointerProperties[] oldTempPointerProperties = mTempPointerProperties;
300305
mTempPointerProperties = new PointerProperties[size];
306+
if (oldTempPointerProperties != null) {
307+
System.arraycopy(oldTempPointerProperties, 0, mTempPointerProperties, 0, oldSize);
308+
}
301309
}
302310
for (int i = oldSize; i < size; i++) {
303311
mTempPointerProperties[i] = new PointerProperties();
@@ -324,7 +332,7 @@ private void transitionToState(int state) {
324332
Slog.i(LOG_TAG, "mCurrentState: STATE_PANNING");
325333
} break;
326334
case STATE_DECIDE_PAN_OR_SCALE: {
327-
Slog.i(LOG_TAG, "mCurrentState: STATE_DETECTING_PAN_OR_SCALE");
335+
Slog.i(LOG_TAG, "mCurrentState: STATE_DECIDE_PAN_OR_SCALE");
328336
} break;
329337
default: {
330338
throw new IllegalArgumentException("Unknown state: " + state);
@@ -397,6 +405,7 @@ public boolean onScale(ScaleGestureDetector detector) {
397405
}
398406
if (scaleDelta > DETECT_SCALING_THRESHOLD) {
399407
performScale(detector, true);
408+
clear();
400409
transitionToState(STATE_SCALING);
401410
return false;
402411
}
@@ -409,8 +418,9 @@ public boolean onScale(ScaleGestureDetector detector) {
409418
Slog.i(LOG_TAG, "panDelta: " + panDelta);
410419
}
411420
if (panDelta > mScaledDetectPanningThreshold) {
412-
transitionToState(STATE_PANNING);
413421
performPan(detector, true);
422+
clear();
423+
transitionToState(STATE_PANNING);
414424
return false;
415425
}
416426
} break;

0 commit comments

Comments
 (0)