am 5cbd4839: Merge "more fixes to monkey motion event timing" into jb-dev
* commit '5cbd4839f28b5f33573e926e24c204036c7baa73': more fixes to monkey motion event timing
This commit is contained in:
@@ -328,7 +328,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
try {
|
try {
|
||||||
float x = Float.parseFloat(args[0]);
|
float x = Float.parseFloat(args[0]);
|
||||||
float y = Float.parseFloat(args[1]);
|
float y = Float.parseFloat(args[1]);
|
||||||
long tapDuration = 0;
|
long tapDuration = 5;
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
tapDuration = Long.parseLong(args[2]);
|
tapDuration = Long.parseLong(args[2]);
|
||||||
}
|
}
|
||||||
@@ -396,6 +396,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
long downTime = SystemClock.uptimeMillis();
|
long downTime = SystemClock.uptimeMillis();
|
||||||
long eventTime = SystemClock.uptimeMillis();
|
long eventTime = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
|
MonkeyWaitEvent wayPointDelay = new MonkeyWaitEvent(5);
|
||||||
if (stepCount > 0) {
|
if (stepCount > 0) {
|
||||||
float xStep = (xEnd - xStart) / stepCount;
|
float xStep = (xEnd - xStart) / stepCount;
|
||||||
float yStep = (yEnd - yStart) / stepCount;
|
float yStep = (yEnd - yStart) / stepCount;
|
||||||
@@ -406,6 +407,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
mQ.addLast(e);
|
mQ.addLast(e);
|
||||||
|
|
||||||
for (int i = 0; i < stepCount; ++i) {
|
for (int i = 0; i < stepCount; ++i) {
|
||||||
|
mQ.addLast(wayPointDelay);
|
||||||
x += xStep;
|
x += xStep;
|
||||||
y += yStep;
|
y += yStep;
|
||||||
eventTime = SystemClock.uptimeMillis();
|
eventTime = SystemClock.uptimeMillis();
|
||||||
@@ -414,6 +416,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
mQ.addLast(e);
|
mQ.addLast(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mQ.addLast(wayPointDelay);
|
||||||
eventTime = SystemClock.uptimeMillis();
|
eventTime = SystemClock.uptimeMillis();
|
||||||
e = new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downTime)
|
e = new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downTime)
|
||||||
.setEventTime(eventTime).addPointer(0, x, y, 1, 5);
|
.setEventTime(eventTime).addPointer(0, x, y, 1, 5);
|
||||||
@@ -808,16 +811,24 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
/**
|
/**
|
||||||
* Adjust motion downtime and eventtime according to current system time.
|
* Adjust motion downtime and eventtime according to current system time.
|
||||||
*
|
*
|
||||||
* @param e A KeyEvent
|
* @param e A MotionEvent
|
||||||
*/
|
*/
|
||||||
private void adjustMotionEventTime(MonkeyMotionEvent e) {
|
private void adjustMotionEventTime(MonkeyMotionEvent e) {
|
||||||
long updatedDownTime = 0;
|
long thisEventTime = SystemClock.uptimeMillis();
|
||||||
|
long thisDownTime = e.getDownTime();
|
||||||
|
|
||||||
updatedDownTime = SystemClock.uptimeMillis();
|
if (thisDownTime == mLastRecordedDownTimeMotion) {
|
||||||
if (e.getDownTime() < 0) {
|
// this event is the same batch as previous one
|
||||||
e.setDownTime(updatedDownTime);
|
e.setDownTime(mLastExportDownTimeMotion);
|
||||||
|
} else {
|
||||||
|
// this event is the start of a new batch
|
||||||
|
mLastRecordedDownTimeMotion = thisDownTime;
|
||||||
|
// update down time to match current time
|
||||||
|
e.setDownTime(thisEventTime);
|
||||||
|
mLastExportDownTimeMotion = thisEventTime;
|
||||||
}
|
}
|
||||||
e.setEventTime(updatedDownTime);
|
// always refresh event time
|
||||||
|
e.setEventTime(thisEventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user