summaryrefslogtreecommitdiff
path: root/cmds/input
diff options
context:
space:
mode:
authorSiarhei Vishniakou <svv@google.com>2018-05-09 09:54:43 -0700
committerSiarhei Vishniakou <svv@google.com>2018-05-22 07:23:34 -0700
commitde1f904713e00045ad545ecb0ad51d83f9ca0e42 (patch)
treee7c1f59d895e3ad3599a7456fb52675c155f1fc8 /cmds/input
parentdfe3c2206966fcfc18c5b4b3601fd2915869a0f0 (diff)
Allow keycode lookup without KEYCODE_ prefix
Currently, KeyEvent.keyCodeFromString(String name) requires the string to either start with "KEYCODE_", or be directly convertible to an int. However, the string representation of every keycode starts with "KEYCODE_", so this requirement is redundant. Relax this requirement to alllow both of the following usages: 1) keyCodeFromString("KEYCODE_BUTTON_A") 2) keyCodeFromString("BUTTON_A") Currently, only 1) is supported. The other usage, 3) keyCodeFromString("29") is unchanged. The input is no longer case-sensitive. Improved the example of usage in the documentation: the input "1001" suggests that the string must contain binary representation for usage 3), while in fact it is supposed to be a base 10 number. Test: atest cts.KeyEventTest#testKeyCodeFromString Bug: 36069459 Change-Id: I54d7f9d1270748854143cc9d1e8af48c9ec0cd0f
Diffstat (limited to 'cmds/input')
-rw-r--r--cmds/input/src/com/android/commands/input/Input.java3
1 files changed, 0 insertions, 3 deletions
diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java
index d3ec32076292..74edffb4738d 100644
--- a/cmds/input/src/com/android/commands/input/Input.java
+++ b/cmds/input/src/com/android/commands/input/Input.java
@@ -91,9 +91,6 @@ public class Input {
if (args.length > start) {
for (int i = start; i < args.length; i++) {
int keyCode = KeyEvent.keyCodeFromString(args[i]);
- if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
- keyCode = KeyEvent.keyCodeFromString("KEYCODE_" + args[i]);
- }
sendKeyEvent(inputSource, keyCode, longpress);
}
return;