Bug 999750 - Recycle MotionEvents. r=kats

This commit is contained in:
Michael Comella 2014-04-23 18:04:51 -07:00
Родитель e7a3e4257d
Коммит d2dd1c7253
3 изменённых файлов: 27 добавлений и 5 удалений

Просмотреть файл

@ -254,6 +254,8 @@ final class TouchEventHandler implements Tabs.OnTabsChangedListener {
if (event != null) {
dispatchEvent(event, allowDefaultAction);
event.recycle();
event = null;
}
if (mEventQueue.isEmpty()) {
// we have processed the backlog of events, and are all caught up.

Просмотреть файл

@ -26,7 +26,12 @@ class MotionEventHelper {
Log.d(LOGTAG, "Triggering down at (" + x + "," + y + ")");
long downTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, mSurfaceOffsetX + x, mSurfaceOffsetY + y, 0);
mInstrumentation.sendPointerSync(event);
try {
mInstrumentation.sendPointerSync(event);
} finally {
event.recycle();
event = null;
}
return downTime;
}
@ -37,7 +42,12 @@ class MotionEventHelper {
public long move(long downTime, long moveTime, float x, float y) {
Log.d(LOGTAG, "Triggering move to (" + x + "," + y + ")");
MotionEvent event = MotionEvent.obtain(downTime, moveTime, MotionEvent.ACTION_MOVE, mSurfaceOffsetX + x, mSurfaceOffsetY + y, 0);
mInstrumentation.sendPointerSync(event);
try {
mInstrumentation.sendPointerSync(event);
} finally {
event.recycle();
event = null;
}
return downTime;
}
@ -48,7 +58,12 @@ class MotionEventHelper {
public long up(long downTime, long upTime, float x, float y) {
Log.d(LOGTAG, "Triggering up at (" + x + "," + y + ")");
MotionEvent event = MotionEvent.obtain(downTime, upTime, MotionEvent.ACTION_UP, mSurfaceOffsetX + x, mSurfaceOffsetY + y, 0);
mInstrumentation.sendPointerSync(event);
try {
mInstrumentation.sendPointerSync(event);
} finally {
event.recycle();
event = null;
}
return -1L;
}

Просмотреть файл

@ -203,8 +203,13 @@ class MotionEventReplayer {
eventTime * 1000000, action, pointerCount, pointerIds, (float[])pointerData,
metaState, xPrecision, yPrecision, deviceId, edgeFlags);
}
Log.v(LOGTAG, "Injecting " + event.toString());
mInstrumentation.sendPointerSync(event);
try {
Log.v(LOGTAG, "Injecting " + event.toString());
mInstrumentation.sendPointerSync(event);
} finally {
event.recycle();
event = null;
}
eventProperties.clear();
}