feat: SystemInputUtils不再处理swipe动作

This commit is contained in:
2026-07-17 10:34:00 +08:00
parent 474c7942a3
commit 5fb7b58fc3
4 changed files with 23 additions and 15 deletions

View File

@@ -79,6 +79,7 @@ public class InputCommandHandler {
float relY = (float) command.getY();
int x = (int) (relX * screenWidth);
int y = (int) (relY * screenHeight);
Log.d(TAG, "Motion event: " + action + " at: " + x + ", " + y);
inputExecutor.injectMotionEvent(action, x, y);
}

View File

@@ -54,18 +54,18 @@ public class SystemInputUtils implements InputExecutor {
@Override
public void injectSwipe(int x1, int y1, int x2, int y2, long duration) {
long downTime = SystemClock.uptimeMillis();
injectMotionEvent(downTime, downTime, MotionEvent.ACTION_DOWN, x1, y1);
int steps = 10;
for (int i = 1; i <= steps; i++) {
SystemClock.sleep(duration / steps);
int x = x1 + (x2 - x1) * i / steps;
int y = y1 + (y2 - y1) * i / steps;
injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y);
}
injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x2, y2);
// long downTime = SystemClock.uptimeMillis();
// injectMotionEvent(downTime, downTime, MotionEvent.ACTION_DOWN, x1, y1);
//
// int steps = 10;
// for (int i = 1; i <= steps; i++) {
// SystemClock.sleep(duration / steps);
// int x = x1 + (x2 - x1) * i / steps;
// int y = y1 + (y2 - y1) * i / steps;
// injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y);
// }
//
// injectMotionEvent(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x2, y2);
}
@Override