diff options
author | Bill Napier <napier@google.com> | 2012-03-05 09:49:27 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-05 09:49:27 -0800 |
commit | 339fa32291f94d01e38575f54ea9f926fc3c808f (patch) | |
tree | 2acf6b089d4d8f6981f141e0732c1ff9e7a38fe4 /cmds | |
parent | c622a9dd847483dc2be3e0ec5ede03a8dc09831b (diff) | |
parent | 3d3d64250d93c63feef732e873632a67995e242f (diff) | |
download | android_development-339fa32291f94d01e38575f54ea9f926fc3c808f.tar.gz android_development-339fa32291f94d01e38575f54ea9f926fc3c808f.tar.bz2 android_development-339fa32291f94d01e38575f54ea9f926fc3c808f.zip |
Merge "Fix UNKNOWN keycode parsing in monkey."
Diffstat (limited to 'cmds')
3 files changed, 10 insertions, 3 deletions
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java index c5b25e6b6..99e7c0760 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java @@ -247,13 +247,17 @@ public class MonkeySourceNetwork implements MonkeyEventSource { // Ok, it wasn't a number, see if we have a // keycode name for it keyCode = MonkeySourceRandom.getKeyCode(keyName); - if (keyCode == -1) { + if (keyCode == KeyEvent.KEYCODE_UNKNOWN) { // OK, one last ditch effort to find a match. // Build the KEYCODE_STRING from the string // we've been given and see if that key // exists. This would allow you to do "key // down menu", for example. keyCode = MonkeySourceRandom.getKeyCode("KEYCODE_" + keyName.toUpperCase()); + if (keyCode == KeyEvent.KEYCODE_UNKNOWN) { + // Still unknown + return -1; + } } } return keyCode; diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java index af740b328..c18152bf0 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java @@ -102,7 +102,7 @@ public class MonkeySourceRandom implements MonkeyEventSource { * be an expensive operation. * * @param keyName the name of the KEYCODE_VALUE to lookup. - * @returns the intenger keyCode value, or -1 if not found + * @returns the intenger keyCode value, or KeyEvent.KEYCODE_UNKNOWN if not found */ public static int getKeyCode(String keyName) { return KeyEvent.keyCodeFromString(keyName); diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java index 4748a25c2..5b050bfec 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java @@ -547,6 +547,9 @@ public class MonkeySourceScript implements MonkeyEventSource { if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) { String key_name = args[0]; int keyCode = MonkeySourceRandom.getKeyCode(key_name); + if (keyCode == KeyEvent.KEYCODE_UNKNOWN) { + return; + } MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, keyCode); mQ.addLast(e); e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, keyCode); @@ -772,7 +775,7 @@ public class MonkeySourceScript implements MonkeyEventSource { if (e.getEventTime() < 0) { return; - } + } updatedDownTime = SystemClock.uptimeMillis(); e.setDownTime(updatedDownTime); e.setEventTime(updatedDownTime); |