fix: 优化滑动卡顿

This commit is contained in:
2026-07-15 16:21:49 +08:00
parent fa2f27fbd0
commit 92ad90cbeb

View File

@@ -18,6 +18,7 @@ public class SystemInputUtils implements InputExecutor {
private Object mInputManager; private Object mInputManager;
private Method mInjectInputEventMethod; private Method mInjectInputEventMethod;
private static final int INJECT_INPUT_EVENT_MODE_ASYNC = 0;
private static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2; private static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2;
private long mDownTime; private long mDownTime;
@@ -87,7 +88,7 @@ public class SystemInputUtils implements InputExecutor {
MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, 0); MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, 0);
event.setSource(InputDevice.SOURCE_TOUCHSCREEN); event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
try { try {
mInjectInputEventMethod.invoke(mInputManager, event, INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); mInjectInputEventMethod.invoke(mInputManager, event, INJECT_INPUT_EVENT_MODE_ASYNC);
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Error injecting motion event", e); Log.e(TAG, "Error injecting motion event", e);
} finally { } finally {
@@ -98,7 +99,7 @@ public class SystemInputUtils implements InputExecutor {
private void injectKeyEvent(long downTime, long eventTime, int action, int keyCode) { private void injectKeyEvent(long downTime, long eventTime, int action, int keyCode) {
KeyEvent event = new KeyEvent(downTime, eventTime, action, keyCode, 0); KeyEvent event = new KeyEvent(downTime, eventTime, action, keyCode, 0);
try { try {
mInjectInputEventMethod.invoke(mInputManager, event, INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); mInjectInputEventMethod.invoke(mInputManager, event, INJECT_INPUT_EVENT_MODE_ASYNC);
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Error injecting key event", e); Log.e(TAG, "Error injecting key event", e);
} }