diff options
author | Guang Zhu <guangzhu@google.com> | 2012-05-04 12:52:34 -0700 |
---|---|---|
committer | Guang Zhu <guangzhu@google.com> | 2012-05-04 14:06:50 -0700 |
commit | 77dc0d2eabf5ae5cf8a5da8d51700daff1b30aab (patch) | |
tree | d83a77fa90ce2b3e5ce5478dcbd9a68916332f9e /cmds | |
parent | a8863a96142779d89b65f71a5cab4e2ad1e6fd97 (diff) | |
download | android_development-77dc0d2eabf5ae5cf8a5da8d51700daff1b30aab.tar.gz android_development-77dc0d2eabf5ae5cf8a5da8d51700daff1b30aab.tar.bz2 android_development-77dc0d2eabf5ae5cf8a5da8d51700daff1b30aab.zip |
more fixes to monkey motion event timing
Last attempt to fix ACTION_MOVE ended up breaking stuff
elsewhere.
For a touch based gesture, it usually have a group of motion
events, and typically they have the same down time and individual
event times. Example: a tap should have ACTION_DOWN with same
down time and event time, and subsequent ACTION_UP should have
the same down time as previous one, but a fresh event time.
Similar situation applies to ACTION_DOWN, ACTION_MOVEs,
ACTION_UP sequence of a drag/scroll/fling gesture
In addition, a 5ms delay is added for a tap between DOWN and
UP. And a 5ms delay is added for each injected event in a drag
gesture
Change-Id: I8e65e578152b1c1ff1fa4c0f476ef45806826479
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java index 055ef22b5..05f29cf27 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java @@ -328,7 +328,7 @@ public class MonkeySourceScript implements MonkeyEventSource { try { float x = Float.parseFloat(args[0]); float y = Float.parseFloat(args[1]); - long tapDuration = 0; + long tapDuration = 5; if (args.length == 3) { tapDuration = Long.parseLong(args[2]); } @@ -396,6 +396,7 @@ public class MonkeySourceScript implements MonkeyEventSource { long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); + MonkeyWaitEvent wayPointDelay = new MonkeyWaitEvent(5); if (stepCount > 0) { float xStep = (xEnd - xStart) / stepCount; float yStep = (yEnd - yStart) / stepCount; @@ -406,6 +407,7 @@ public class MonkeySourceScript implements MonkeyEventSource { mQ.addLast(e); for (int i = 0; i < stepCount; ++i) { + mQ.addLast(wayPointDelay); x += xStep; y += yStep; eventTime = SystemClock.uptimeMillis(); @@ -414,6 +416,7 @@ public class MonkeySourceScript implements MonkeyEventSource { mQ.addLast(e); } + mQ.addLast(wayPointDelay); eventTime = SystemClock.uptimeMillis(); e = new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downTime) .setEventTime(eventTime).addPointer(0, x, y, 1, 5); @@ -539,7 +542,7 @@ public class MonkeySourceScript implements MonkeyEventSource { return; } - // Handle launch instrumentation events + // Handle launch instrumentation events if (s.indexOf(EVENT_KEYWORD_INSTRUMENTATION) >= 0 && args.length == 2) { String test_name = args[0]; String runner_name = args[1]; @@ -613,7 +616,7 @@ public class MonkeySourceScript implements MonkeyEventSource { mQ.addLast(e); } - //Run the shell command + //Run the shell command if (s.indexOf(EVENT_KEYWORD_RUNCMD) >= 0 && args.length == 1) { String cmd = args[0]; MonkeyCommandEvent e = new MonkeyCommandEvent(cmd); @@ -808,16 +811,24 @@ public class MonkeySourceScript implements MonkeyEventSource { /** * Adjust motion downtime and eventtime according to current system time. * - * @param e A KeyEvent + * @param e A MotionEvent */ private void adjustMotionEventTime(MonkeyMotionEvent e) { - long updatedDownTime = 0; + long thisEventTime = SystemClock.uptimeMillis(); + long thisDownTime = e.getDownTime(); - updatedDownTime = SystemClock.uptimeMillis(); - if (e.getDownTime() < 0) { - e.setDownTime(updatedDownTime); + if (thisDownTime == mLastRecordedDownTimeMotion) { + // this event is the same batch as previous one + 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); } /** |