Fix UNKNOWN keycode parsing in monkey.
Reported here: http://code.google.com/p/android/issues/detail?id=25369 Change the monkey's keycode parsing code to check KeyEvent.KEYCODE_UNKNOWN instead of -1. Change-Id: I2caa82980b83c49614a318d38c0257a5587c16cd
This commit is contained in:
@@ -247,13 +247,17 @@ public class MonkeySourceNetwork implements MonkeyEventSource {
|
|||||||
// Ok, it wasn't a number, see if we have a
|
// Ok, it wasn't a number, see if we have a
|
||||||
// keycode name for it
|
// keycode name for it
|
||||||
keyCode = MonkeySourceRandom.getKeyCode(keyName);
|
keyCode = MonkeySourceRandom.getKeyCode(keyName);
|
||||||
if (keyCode == -1) {
|
if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||||
// OK, one last ditch effort to find a match.
|
// OK, one last ditch effort to find a match.
|
||||||
// Build the KEYCODE_STRING from the string
|
// Build the KEYCODE_STRING from the string
|
||||||
// we've been given and see if that key
|
// we've been given and see if that key
|
||||||
// exists. This would allow you to do "key
|
// exists. This would allow you to do "key
|
||||||
// down menu", for example.
|
// down menu", for example.
|
||||||
keyCode = MonkeySourceRandom.getKeyCode("KEYCODE_" + keyName.toUpperCase());
|
keyCode = MonkeySourceRandom.getKeyCode("KEYCODE_" + keyName.toUpperCase());
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||||
|
// Still unknown
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return keyCode;
|
return keyCode;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class MonkeySourceRandom implements MonkeyEventSource {
|
|||||||
* be an expensive operation.
|
* be an expensive operation.
|
||||||
*
|
*
|
||||||
* @param keyName the name of the KEYCODE_VALUE to lookup.
|
* @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) {
|
public static int getKeyCode(String keyName) {
|
||||||
return KeyEvent.keyCodeFromString(keyName);
|
return KeyEvent.keyCodeFromString(keyName);
|
||||||
|
|||||||
@@ -547,6 +547,9 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) {
|
if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) {
|
||||||
String key_name = args[0];
|
String key_name = args[0];
|
||||||
int keyCode = MonkeySourceRandom.getKeyCode(key_name);
|
int keyCode = MonkeySourceRandom.getKeyCode(key_name);
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, keyCode);
|
MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, keyCode);
|
||||||
mQ.addLast(e);
|
mQ.addLast(e);
|
||||||
e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, keyCode);
|
e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, keyCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user