diff options
| -rw-r--r-- | core/api/current.txt | 4 | ||||
| -rw-r--r-- | core/api/test-current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/view/KeyEvent.java | 27 | ||||
| -rw-r--r-- | data/keyboards/Generic.kl | 4 | ||||
| -rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 13 |
5 files changed, 48 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 39863949d66d..51c6f6a5eecc 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -50903,6 +50903,10 @@ package android.view { field public static final int KEYCODE_LAST_CHANNEL = 229; // 0xe5 field public static final int KEYCODE_LEFT_BRACKET = 71; // 0x47 field public static final int KEYCODE_M = 41; // 0x29 + field public static final int KEYCODE_MACRO_1 = 313; // 0x139 + field public static final int KEYCODE_MACRO_2 = 314; // 0x13a + field public static final int KEYCODE_MACRO_3 = 315; // 0x13b + field public static final int KEYCODE_MACRO_4 = 316; // 0x13c field public static final int KEYCODE_MANNER_MODE = 205; // 0xcd field public static final int KEYCODE_MEDIA_AUDIO_TRACK = 222; // 0xde field public static final int KEYCODE_MEDIA_CLOSE = 128; // 0x80 diff --git a/core/api/test-current.txt b/core/api/test-current.txt index e93467b90e68..8d90f9ad2a42 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -3332,7 +3332,7 @@ package android.view { method public static String actionToString(int); method public final void setDisplayId(int); field public static final int FLAG_IS_ACCESSIBILITY_EVENT = 2048; // 0x800 - field public static final int LAST_KEYCODE = 312; // 0x138 + field public static final int LAST_KEYCODE = 316; // 0x13c } public final class KeyboardShortcutGroup implements android.os.Parcelable { diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 2af025469df4..b6d9400fad5c 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -897,13 +897,38 @@ public class KeyEvent extends InputEvent implements Parcelable { * This key is handled by the framework and is never delivered to applications. */ public static final int KEYCODE_RECENT_APPS = 312; + /** + * Key code constant: A button whose usage can be customized by the user through + * the system. + * User customizable key #1. + */ + public static final int KEYCODE_MACRO_1 = 313; + /** + * Key code constant: A button whose usage can be customized by the user through + * the system. + * User customizable key #2. + */ + public static final int KEYCODE_MACRO_2 = 314; + /** + * Key code constant: A button whose usage can be customized by the user through + * the system. + * User customizable key #3. + */ + public static final int KEYCODE_MACRO_3 = 315; + /** + * Key code constant: A button whose usage can be customized by the user through + * the system. + * User customizable key #4. + */ + public static final int KEYCODE_MACRO_4 = 316; + /** * Integer value of the last KEYCODE. Increases as new keycodes are added to KeyEvent. * @hide */ @TestApi - public static final int LAST_KEYCODE = KEYCODE_RECENT_APPS; + public static final int LAST_KEYCODE = KEYCODE_MACRO_4; // NOTE: If you add a new keycode here you must also add it to: // isSystem() diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl index 247d484d77ea..e27cd978e6be 100644 --- a/data/keyboards/Generic.kl +++ b/data/keyboards/Generic.kl @@ -424,6 +424,10 @@ key 580 APP_SWITCH key 582 VOICE_ASSIST # Linux KEY_ASSISTANT key 583 ASSIST +key 656 MACRO_1 +key 657 MACRO_2 +key 658 MACRO_3 +key 659 MACRO_4 # Keys defined by HID usages key usage 0x0c0067 WINDOW diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index b32e8f0b3221..ee2e4589e1aa 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -3259,6 +3259,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { Slog.wtf(TAG, "KEYCODE_STYLUS_BUTTON_* should be handled in" + " interceptKeyBeforeQueueing"); return key_consumed; + case KeyEvent.KEYCODE_MACRO_1: + case KeyEvent.KEYCODE_MACRO_2: + case KeyEvent.KEYCODE_MACRO_3: + case KeyEvent.KEYCODE_MACRO_4: + Slog.wtf(TAG, "KEYCODE_MACRO_x should be handled in interceptKeyBeforeQueueing"); + return key_consumed; } if (isValidGlobalKey(keyCode) @@ -4396,6 +4402,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { result &= ~ACTION_PASS_TO_USER; break; } + case KeyEvent.KEYCODE_MACRO_1: + case KeyEvent.KEYCODE_MACRO_2: + case KeyEvent.KEYCODE_MACRO_3: + case KeyEvent.KEYCODE_MACRO_4: + // TODO(b/266098478): Add logic to handle KEYCODE_MACROx feature + result &= ~ACTION_PASS_TO_USER; + break; } if (useHapticFeedback) { |