Add TestAPIs to test InputDevice#getKeyCodeForKeyLocation().
Mention @RequiredPermission(..) where applicable / move it from javadocs. Bug: 179812917 Test: atest KeyboardLayoutChangeTest Test: atest android.hardware.input.cts.tests -m Change-Id: I183734d3bb80a6f0c69f27629bfaaa577e4fab59
This commit is contained in:
@@ -38,6 +38,7 @@ package android {
|
||||
field public static final String RESET_APP_ERRORS = "android.permission.RESET_APP_ERRORS";
|
||||
field public static final String REVOKE_POST_NOTIFICATIONS_WITHOUT_KILL = "android.permission.REVOKE_POST_NOTIFICATIONS_WITHOUT_KILL";
|
||||
field public static final String SET_AND_VERIFY_LOCKSCREEN_CREDENTIALS = "android.permission.SET_AND_VERIFY_LOCKSCREEN_CREDENTIALS";
|
||||
field public static final String SET_KEYBOARD_LAYOUT = "android.permission.SET_KEYBOARD_LAYOUT";
|
||||
field public static final String START_TASKS_FROM_RECENTS = "android.permission.START_TASKS_FROM_RECENTS";
|
||||
field public static final String SUSPEND_APPS = "android.permission.SUSPEND_APPS";
|
||||
field public static final String TEST_BIOMETRIC = "android.permission.TEST_BIOMETRIC";
|
||||
@@ -1189,9 +1190,23 @@ package android.hardware.hdmi {
|
||||
|
||||
package android.hardware.input {
|
||||
|
||||
public final class InputDeviceIdentifier implements android.os.Parcelable {
|
||||
ctor public InputDeviceIdentifier(@NonNull String, int, int);
|
||||
method public int describeContents();
|
||||
method @NonNull public String getDescriptor();
|
||||
method public int getProductId();
|
||||
method public int getVendorId();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.hardware.input.InputDeviceIdentifier> CREATOR;
|
||||
}
|
||||
|
||||
public final class InputManager {
|
||||
method public int getBlockUntrustedTouchesMode(@NonNull android.content.Context);
|
||||
method @Nullable public String getCurrentKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier);
|
||||
method @NonNull public java.util.List<java.lang.String> getKeyboardLayoutDescriptorsForInputDevice(@NonNull android.view.InputDevice);
|
||||
method @RequiresPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT) public void removeKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier, @NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setBlockUntrustedTouchesMode(@NonNull android.content.Context, int);
|
||||
method @RequiresPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT) public void setCurrentKeyboardLayoutForInputDevice(@NonNull android.hardware.input.InputDeviceIdentifier, @NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setMaximumObscuringOpacityForTouch(@FloatRange(from=0, to=1) float);
|
||||
field public static final long BLOCK_UNTRUSTED_TOUCHES = 158002302L; // 0x96aec7eL
|
||||
}
|
||||
@@ -2746,6 +2761,7 @@ package android.view {
|
||||
public final class InputDevice implements android.os.Parcelable {
|
||||
method @RequiresPermission("android.permission.DISABLE_INPUT_DEVICE") public void disable();
|
||||
method @RequiresPermission("android.permission.DISABLE_INPUT_DEVICE") public void enable();
|
||||
method @NonNull public android.hardware.input.InputDeviceIdentifier getIdentifier();
|
||||
}
|
||||
|
||||
public class KeyEvent extends android.view.InputEvent implements android.os.Parcelable {
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package android.hardware.input;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.TestApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
@@ -28,12 +30,13 @@ import java.util.Objects;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public final class InputDeviceIdentifier implements Parcelable {
|
||||
private final String mDescriptor;
|
||||
private final int mVendorId;
|
||||
private final int mProductId;
|
||||
|
||||
public InputDeviceIdentifier(String descriptor, int vendorId, int productId) {
|
||||
public InputDeviceIdentifier(@NonNull String descriptor, int vendorId, int productId) {
|
||||
this.mDescriptor = descriptor;
|
||||
this.mVendorId = vendorId;
|
||||
this.mProductId = productId;
|
||||
@@ -51,12 +54,13 @@ public final class InputDeviceIdentifier implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeString(mDescriptor);
|
||||
dest.writeInt(mVendorId);
|
||||
dest.writeInt(mProductId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getDescriptor() {
|
||||
return mDescriptor;
|
||||
}
|
||||
|
||||
@@ -637,6 +637,30 @@ public final class InputManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptors of all supported keyboard layouts appropriate for the specified
|
||||
* input device.
|
||||
* <p>
|
||||
* The input manager consults the built-in keyboard layouts as well as all keyboard layouts
|
||||
* advertised by applications using a {@link #ACTION_QUERY_KEYBOARD_LAYOUTS} broadcast receiver.
|
||||
* </p>
|
||||
*
|
||||
* @param device The input device to query.
|
||||
* @return The ids of all keyboard layouts which are supported by the specified input device.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@NonNull
|
||||
public List<String> getKeyboardLayoutDescriptorsForInputDevice(@NonNull InputDevice device) {
|
||||
KeyboardLayout[] layouts = getKeyboardLayoutsForInputDevice(device.getIdentifier());
|
||||
List<String> res = new ArrayList<>();
|
||||
for (KeyboardLayout kl : layouts) {
|
||||
res.add(kl.getDescriptor());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about all supported keyboard layouts appropriate
|
||||
* for a specific input device.
|
||||
@@ -651,7 +675,9 @@ public final class InputManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public KeyboardLayout[] getKeyboardLayoutsForInputDevice(InputDeviceIdentifier identifier) {
|
||||
@NonNull
|
||||
public KeyboardLayout[] getKeyboardLayoutsForInputDevice(
|
||||
@NonNull InputDeviceIdentifier identifier) {
|
||||
try {
|
||||
return mIm.getKeyboardLayoutsForInputDevice(identifier);
|
||||
} catch (RemoteException ex) {
|
||||
@@ -681,15 +707,17 @@ public final class InputManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current keyboard layout descriptor for the specified input
|
||||
* device.
|
||||
* Gets the current keyboard layout descriptor for the specified input device.
|
||||
*
|
||||
* @param identifier Identifier for the input device
|
||||
* @return The keyboard layout descriptor, or null if no keyboard layout has
|
||||
* been set.
|
||||
* @return The keyboard layout descriptor, or null if no keyboard layout has been set.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public String getCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier) {
|
||||
@TestApi
|
||||
@Nullable
|
||||
public String getCurrentKeyboardLayoutForInputDevice(
|
||||
@NonNull InputDeviceIdentifier identifier) {
|
||||
try {
|
||||
return mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
|
||||
} catch (RemoteException ex) {
|
||||
@@ -698,20 +726,21 @@ public final class InputManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current keyboard layout descriptor for the specified input
|
||||
* device.
|
||||
* Sets the current keyboard layout descriptor for the specified input device.
|
||||
* <p>
|
||||
* This method may have the side-effect of causing the input device in
|
||||
* question to be reconfigured.
|
||||
* This method may have the side-effect of causing the input device in question to be
|
||||
* reconfigured.
|
||||
* </p>
|
||||
*
|
||||
* @param identifier The identifier for the input device.
|
||||
* @param keyboardLayoutDescriptor The keyboard layout descriptor to use,
|
||||
* must not be null.
|
||||
* @param keyboardLayoutDescriptor The keyboard layout descriptor to use, must not be null.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
|
||||
String keyboardLayoutDescriptor) {
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT)
|
||||
public void setCurrentKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier,
|
||||
@NonNull String keyboardLayoutDescriptor) {
|
||||
if (identifier == null) {
|
||||
throw new IllegalArgumentException("identifier must not be null");
|
||||
}
|
||||
@@ -728,11 +757,11 @@ public final class InputManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all keyboard layout descriptors that are enabled for the specified
|
||||
* input device.
|
||||
* Gets all keyboard layout descriptors that are enabled for the specified input device.
|
||||
*
|
||||
* @param identifier The identifier for the input device.
|
||||
* @return The keyboard layout descriptors.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public String[] getEnabledKeyboardLayoutsForInputDevice(InputDeviceIdentifier identifier) {
|
||||
@@ -750,15 +779,16 @@ public final class InputManager {
|
||||
/**
|
||||
* Adds the keyboard layout descriptor for the specified input device.
|
||||
* <p>
|
||||
* This method may have the side-effect of causing the input device in
|
||||
* question to be reconfigured.
|
||||
* This method may have the side-effect of causing the input device in question to be
|
||||
* reconfigured.
|
||||
* </p>
|
||||
*
|
||||
* @param identifier The identifier for the input device.
|
||||
* @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
|
||||
* add.
|
||||
* @param keyboardLayoutDescriptor The descriptor of the keyboard layout to add.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT)
|
||||
public void addKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
|
||||
String keyboardLayoutDescriptor) {
|
||||
if (identifier == null) {
|
||||
@@ -778,17 +808,19 @@ public final class InputManager {
|
||||
/**
|
||||
* Removes the keyboard layout descriptor for the specified input device.
|
||||
* <p>
|
||||
* This method may have the side-effect of causing the input device in
|
||||
* question to be reconfigured.
|
||||
* This method may have the side-effect of causing the input device in question to be
|
||||
* reconfigured.
|
||||
* </p>
|
||||
*
|
||||
* @param identifier The identifier for the input device.
|
||||
* @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
|
||||
* remove.
|
||||
* @param keyboardLayoutDescriptor The descriptor of the keyboard layout to remove.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void removeKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
|
||||
String keyboardLayoutDescriptor) {
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT)
|
||||
public void removeKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier,
|
||||
@NonNull String keyboardLayoutDescriptor) {
|
||||
if (identifier == null) {
|
||||
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
|
||||
}
|
||||
|
||||
@@ -572,6 +572,8 @@ public final class InputDevice implements Parcelable {
|
||||
* @return The identifier object for this device
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@NonNull
|
||||
public InputDeviceIdentifier getIdentifier() {
|
||||
return mIdentifier;
|
||||
}
|
||||
|
||||
@@ -4243,7 +4243,8 @@
|
||||
|
||||
<!-- Allows low-level access to setting the keyboard layout.
|
||||
<p>Not for use by third-party applications.
|
||||
@hide -->
|
||||
@hide
|
||||
@TestApi -->
|
||||
<permission android:name="android.permission.SET_KEYBOARD_LAYOUT"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user