fix how monkey adjust timestamps for motion events
Currently for motion events, monkey forces current system uptime onto both down time and event time. This breaks ACTION_MOVE events because the down time of it is supposed to be the time when finger is down. the new logic is: * check down time, if it's invalid (<0), fill in uptime * always update event time with a fresh uptime Bug: 6424997 Change-Id: I0b445815a5015d48c08bebc921c572164874449d
This commit is contained in:
@@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* monkey event queue. It takes a script to produce events sample script format:
|
* monkey event queue. It takes a script to produce events sample script format:
|
||||||
@@ -748,6 +747,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
*
|
*
|
||||||
* @return True if the file exists and the header is valid, false otherwise.
|
* @return True if the file exists and the header is valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
boolean validHeader;
|
boolean validHeader;
|
||||||
try {
|
try {
|
||||||
@@ -763,6 +763,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
return validHeader;
|
return validHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setVerbose(int verbose) {
|
public void setVerbose(int verbose) {
|
||||||
mVerbose = verbose;
|
mVerbose = verbose;
|
||||||
}
|
}
|
||||||
@@ -812,11 +813,10 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
private void adjustMotionEventTime(MonkeyMotionEvent e) {
|
private void adjustMotionEventTime(MonkeyMotionEvent e) {
|
||||||
long updatedDownTime = 0;
|
long updatedDownTime = 0;
|
||||||
|
|
||||||
if (e.getEventTime() < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
updatedDownTime = SystemClock.uptimeMillis();
|
updatedDownTime = SystemClock.uptimeMillis();
|
||||||
e.setDownTime(updatedDownTime);
|
if (e.getDownTime() < 0) {
|
||||||
|
e.setDownTime(updatedDownTime);
|
||||||
|
}
|
||||||
e.setEventTime(updatedDownTime);
|
e.setEventTime(updatedDownTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,6 +830,7 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
* @return The first event in the event queue or null if the end of the file
|
* @return The first event in the event queue or null if the end of the file
|
||||||
* is reached or if an error is encountered reading the file.
|
* is reached or if an error is encountered reading the file.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public MonkeyEvent getNextEvent() {
|
public MonkeyEvent getNextEvent() {
|
||||||
long recordedEventTime = -1;
|
long recordedEventTime = -1;
|
||||||
MonkeyEvent ev;
|
MonkeyEvent ev;
|
||||||
|
|||||||
Reference in New Issue
Block a user