Merge "Update remote input device doc and add IntDef" into tm-dev

This commit is contained in:
Christine Franks
2022-03-02 17:42:17 +00:00
committed by Android (Google) Code Review
2 changed files with 126 additions and 57 deletions

View File

@@ -278,8 +278,8 @@ public final class VirtualDeviceManager {
*
* @param display the display that the events inputted through this device should target
* @param inputDeviceName the name to call this input device
* @param vendorId the vendor id, as defined by uinput's uinput_setup struct (PCI vendor id)
* @param productId the product id, as defined by uinput's uinput_setup struct
* @param vendorId the PCI vendor id
* @param productId the product id, as defined by the vendor
*/
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
@@ -304,8 +304,8 @@ public final class VirtualDeviceManager {
*
* @param display the display that the events inputted through this device should target
* @param inputDeviceName the name to call this input device
* @param vendorId the vendor id, as defined by uinput's uinput_setup struct (PCI vendor id)
* @param productId the product id, as defined by uinput's uinput_setup struct
* @param vendorId the PCI vendor id
* @param productId the product id, as defined by the vendor
*/
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull
@@ -330,8 +330,8 @@ public final class VirtualDeviceManager {
*
* @param display the display that the events inputted through this device should target
* @param inputDeviceName the name to call this input device
* @param vendorId the vendor id, as defined by uinput's uinput_setup struct (PCI vendor id)
* @param productId the product id, as defined by uinput's uinput_setup struct
* @param vendorId the PCI vendor id
* @param productId the product id, as defined by the vendor
*/
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
@NonNull

View File

@@ -56,6 +56,124 @@ public final class VirtualKeyEvent implements Parcelable {
public @interface Action {
}
/**
* The set of allowed keycodes.
* @hide
*/
@IntDef(prefix = { "KEYCODE_" }, value = {
KeyEvent.KEYCODE_0,
KeyEvent.KEYCODE_1,
KeyEvent.KEYCODE_2,
KeyEvent.KEYCODE_3,
KeyEvent.KEYCODE_4,
KeyEvent.KEYCODE_5,
KeyEvent.KEYCODE_6,
KeyEvent.KEYCODE_7,
KeyEvent.KEYCODE_8,
KeyEvent.KEYCODE_9,
KeyEvent.KEYCODE_A,
KeyEvent.KEYCODE_B,
KeyEvent.KEYCODE_C,
KeyEvent.KEYCODE_D,
KeyEvent.KEYCODE_E,
KeyEvent.KEYCODE_F,
KeyEvent.KEYCODE_G,
KeyEvent.KEYCODE_H,
KeyEvent.KEYCODE_I,
KeyEvent.KEYCODE_J,
KeyEvent.KEYCODE_K,
KeyEvent.KEYCODE_L,
KeyEvent.KEYCODE_M,
KeyEvent.KEYCODE_N,
KeyEvent.KEYCODE_O,
KeyEvent.KEYCODE_P,
KeyEvent.KEYCODE_Q,
KeyEvent.KEYCODE_R,
KeyEvent.KEYCODE_S,
KeyEvent.KEYCODE_T,
KeyEvent.KEYCODE_U,
KeyEvent.KEYCODE_V,
KeyEvent.KEYCODE_W,
KeyEvent.KEYCODE_X,
KeyEvent.KEYCODE_Y,
KeyEvent.KEYCODE_Z,
KeyEvent.KEYCODE_F1,
KeyEvent.KEYCODE_F2,
KeyEvent.KEYCODE_F3,
KeyEvent.KEYCODE_F4,
KeyEvent.KEYCODE_F5,
KeyEvent.KEYCODE_F6,
KeyEvent.KEYCODE_F7,
KeyEvent.KEYCODE_F8,
KeyEvent.KEYCODE_F9,
KeyEvent.KEYCODE_F10,
KeyEvent.KEYCODE_F11,
KeyEvent.KEYCODE_F12,
KeyEvent.KEYCODE_NUMPAD_0,
KeyEvent.KEYCODE_NUMPAD_1,
KeyEvent.KEYCODE_NUMPAD_2,
KeyEvent.KEYCODE_NUMPAD_3,
KeyEvent.KEYCODE_NUMPAD_4,
KeyEvent.KEYCODE_NUMPAD_5,
KeyEvent.KEYCODE_NUMPAD_6,
KeyEvent.KEYCODE_NUMPAD_7,
KeyEvent.KEYCODE_NUMPAD_8,
KeyEvent.KEYCODE_NUMPAD_9,
KeyEvent.KEYCODE_NUMPAD_DIVIDE,
KeyEvent.KEYCODE_NUMPAD_MULTIPLY,
KeyEvent.KEYCODE_NUMPAD_SUBTRACT,
KeyEvent.KEYCODE_NUMPAD_ADD,
KeyEvent.KEYCODE_NUMPAD_DOT,
KeyEvent.KEYCODE_NUMPAD_COMMA,
KeyEvent.KEYCODE_NUMPAD_ENTER,
KeyEvent.KEYCODE_NUMPAD_EQUALS,
KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN,
KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN,
KeyEvent.KEYCODE_GRAVE,
KeyEvent.KEYCODE_MINUS,
KeyEvent.KEYCODE_EQUALS,
KeyEvent.KEYCODE_LEFT_BRACKET,
KeyEvent.KEYCODE_RIGHT_BRACKET,
KeyEvent.KEYCODE_BACKSLASH,
KeyEvent.KEYCODE_SEMICOLON,
KeyEvent.KEYCODE_APOSTROPHE,
KeyEvent.KEYCODE_COMMA,
KeyEvent.KEYCODE_PERIOD,
KeyEvent.KEYCODE_SLASH,
KeyEvent.KEYCODE_ALT_LEFT,
KeyEvent.KEYCODE_ALT_RIGHT,
KeyEvent.KEYCODE_CTRL_LEFT,
KeyEvent.KEYCODE_CTRL_RIGHT,
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent.KEYCODE_SHIFT_RIGHT,
KeyEvent.KEYCODE_META_LEFT,
KeyEvent.KEYCODE_META_RIGHT,
KeyEvent.KEYCODE_CAPS_LOCK,
KeyEvent.KEYCODE_SCROLL_LOCK,
KeyEvent.KEYCODE_NUM_LOCK,
KeyEvent.KEYCODE_ENTER,
KeyEvent.KEYCODE_TAB,
KeyEvent.KEYCODE_SPACE,
KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_UP,
KeyEvent.KEYCODE_DPAD_LEFT,
KeyEvent.KEYCODE_DPAD_RIGHT,
KeyEvent.KEYCODE_MOVE_END,
KeyEvent.KEYCODE_MOVE_HOME,
KeyEvent.KEYCODE_PAGE_DOWN,
KeyEvent.KEYCODE_PAGE_UP,
KeyEvent.KEYCODE_DEL,
KeyEvent.KEYCODE_FORWARD_DEL,
KeyEvent.KEYCODE_INSERT,
KeyEvent.KEYCODE_ESCAPE,
KeyEvent.KEYCODE_BREAK,
KeyEvent.KEYCODE_BACK,
KeyEvent.KEYCODE_FORWARD,
})
@Retention(RetentionPolicy.SOURCE)
public @interface SupportedKeycode {
}
private final @Action int mAction;
private final int mKeyCode;
@@ -114,60 +232,11 @@ public final class VirtualKeyEvent implements Parcelable {
}
/**
* Sets the Android key code of the event. The set of allowed keys include digits
* {@link android.view.KeyEvent#KEYCODE_0} through
* {@link android.view.KeyEvent#KEYCODE_9}, characters
* {@link android.view.KeyEvent#KEYCODE_A} through
* {@link android.view.KeyEvent#KEYCODE_Z}, function keys
* {@link android.view.KeyEvent#KEYCODE_F1} through
* {@link android.view.KeyEvent#KEYCODE_F12}, numpad keys
* {@link android.view.KeyEvent#KEYCODE_NUMPAD_0} through
* {@link android.view.KeyEvent#KEYCODE_NUMPAD_RIGHT_PAREN},
* and these additional keys:
* {@link android.view.KeyEvent#KEYCODE_GRAVE}
* {@link android.view.KeyEvent#KEYCODE_MINUS}
* {@link android.view.KeyEvent#KEYCODE_EQUALS}
* {@link android.view.KeyEvent#KEYCODE_LEFT_BRACKET}
* {@link android.view.KeyEvent#KEYCODE_RIGHT_BRACKET}
* {@link android.view.KeyEvent#KEYCODE_BACKSLASH}
* {@link android.view.KeyEvent#KEYCODE_SEMICOLON}
* {@link android.view.KeyEvent#KEYCODE_APOSTROPHE}
* {@link android.view.KeyEvent#KEYCODE_COMMA}
* {@link android.view.KeyEvent#KEYCODE_PERIOD}
* {@link android.view.KeyEvent#KEYCODE_SLASH}
* {@link android.view.KeyEvent#KEYCODE_ALT_LEFT}
* {@link android.view.KeyEvent#KEYCODE_ALT_RIGHT}
* {@link android.view.KeyEvent#KEYCODE_CTRL_LEFT}
* {@link android.view.KeyEvent#KEYCODE_CTRL_RIGHT}
* {@link android.view.KeyEvent#KEYCODE_SHIFT_LEFT}
* {@link android.view.KeyEvent#KEYCODE_SHIFT_RIGHT}
* {@link android.view.KeyEvent#KEYCODE_META_LEFT}
* {@link android.view.KeyEvent#KEYCODE_META_RIGHT}
* {@link android.view.KeyEvent#KEYCODE_CAPS_LOCK}
* {@link android.view.KeyEvent#KEYCODE_SCROLL_LOCK}
* {@link android.view.KeyEvent#KEYCODE_NUM_LOCK}
* {@link android.view.KeyEvent#KEYCODE_ENTER}
* {@link android.view.KeyEvent#KEYCODE_TAB}
* {@link android.view.KeyEvent#KEYCODE_SPACE}
* {@link android.view.KeyEvent#KEYCODE_DPAD_DOWN}
* {@link android.view.KeyEvent#KEYCODE_DPAD_UP}
* {@link android.view.KeyEvent#KEYCODE_DPAD_LEFT}
* {@link android.view.KeyEvent#KEYCODE_DPAD_RIGHT}
* {@link android.view.KeyEvent#KEYCODE_MOVE_END}
* {@link android.view.KeyEvent#KEYCODE_MOVE_HOME}
* {@link android.view.KeyEvent#KEYCODE_PAGE_DOWN}
* {@link android.view.KeyEvent#KEYCODE_PAGE_UP}
* {@link android.view.KeyEvent#KEYCODE_DEL}
* {@link android.view.KeyEvent#KEYCODE_FORWARD_DEL}
* {@link android.view.KeyEvent#KEYCODE_INSERT}
* {@link android.view.KeyEvent#KEYCODE_ESCAPE}
* {@link android.view.KeyEvent#KEYCODE_BREAK}
* {@link android.view.KeyEvent#KEYCODE_BACK}
* {@link android.view.KeyEvent#KEYCODE_FORWARD}
* Sets the Android key code of the event.
*
* @return this builder, to allow for chaining of calls
*/
public @NonNull Builder setKeyCode(int keyCode) {
public @NonNull Builder setKeyCode(@SupportedKeycode int keyCode) {
mKeyCode = keyCode;
return this;
}