Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 973efa08 authored by Michael Wright's avatar Michael Wright
Browse files

Only translate prefixed strings to keys / axes.

In order to maintain compatibility, we need to only translate strings
prefixed with KEYCODE_ or AXIS_ into the appropriate key codes /
axes. Otherwise things like `adb shell input` will convert 4 into
KEYCODE_4 whereas before it would convert it into KEYCODE_BACK.

Bug: 14807833
Change-Id: I2cb41aa55dbb2e3fd62664c1b944877290d7e4be
parent 58bfed92
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2698,11 +2698,11 @@ public class KeyEvent extends InputEvent implements Parcelable {
    public static int keyCodeFromString(String symbolicName) {
        if (symbolicName.startsWith(LABEL_PREFIX)) {
            symbolicName = symbolicName.substring(LABEL_PREFIX.length());
        }
            int keyCode = nativeKeyCodeFromString(symbolicName);
            if (keyCode > 0) {
                return keyCode;
            }
        }
        try {
            return Integer.parseInt(symbolicName, 10);
        } catch (NumberFormatException ex) {
+4 −4
Original line number Diff line number Diff line
@@ -3070,11 +3070,11 @@ public final class MotionEvent extends InputEvent implements Parcelable {
    public static int axisFromString(String symbolicName) {
        if (symbolicName.startsWith(LABEL_PREFIX)) {
            symbolicName = symbolicName.substring(LABEL_PREFIX.length());
        }
            int axis = nativeAxisFromString(symbolicName);
            if (axis >= 0) {
                return axis;
            }
        }
        try {
            return Integer.parseInt(symbolicName, 10);
        } catch (NumberFormatException ex) {