From 8749a298c0a94df8fc511bdd08fef4a59d0fadf7 Mon Sep 17 00:00:00 2001 From: Guang Zhu Date: Tue, 1 May 2012 12:35:29 -0700 Subject: [PATCH] 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 --- .../android/commands/monkey/MonkeySourceScript.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java index d65440b97..055ef22b5 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.NoSuchElementException; import java.util.Random; -import android.util.Log; /** * 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. */ + @Override public boolean validate() { boolean validHeader; try { @@ -763,6 +763,7 @@ public class MonkeySourceScript implements MonkeyEventSource { return validHeader; } + @Override public void setVerbose(int verbose) { mVerbose = verbose; } @@ -812,11 +813,10 @@ public class MonkeySourceScript implements MonkeyEventSource { private void adjustMotionEventTime(MonkeyMotionEvent e) { long updatedDownTime = 0; - if (e.getEventTime() < 0) { - return; - } updatedDownTime = SystemClock.uptimeMillis(); - e.setDownTime(updatedDownTime); + if (e.getDownTime() < 0) { + e.setDownTime(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 * is reached or if an error is encountered reading the file. */ + @Override public MonkeyEvent getNextEvent() { long recordedEventTime = -1; MonkeyEvent ev;