float stepX = (endX - startX) / (float) SWIPE_STEP_COUNT;
float stepY = (endY - startY) / (float) SWIPE_STEP_COUNT;
long downTime = System.currentTimeMillis() - SWIPE_DURATION;
long eventTime = downTime;
MotionEvent downEvent = convertMouseEvent2MotionEvent(ACTION_DOWN, x, y, downTime);
res.add(newMotionEventEnvelope(downEvent));
for (int i = 0; i < SWIPE_STEP_COUNT - 1; i++) {
x += stepX;
y += stepY;
eventTime += SWIPE_STEP_DURATION;
MotionEvent moveEvent = convertMouseEvent2MotionEvent(ACTION_MOVE, x, y, downTime);
moveEvent.eventTime = eventTime;
res.add(newMotionEventEnvelope(moveEvent));
}
x += stepX;
y += stepY;
eventTime += SWIPE_STEP_DURATION;
MotionEvent upEvent = convertMouseEvent2MotionEvent(ACTION_UP, x, y, downTime);
upEvent.eventTime = eventTime;
res.add(newMotionEventEnvelope(upEvent));
return res;
}