Loading core/java/android/hardware/input/IInputManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ interface IInputManager { InputDevice getInputDevice(int deviceId); int[] getInputDeviceIds(); // Enable/disable input device. boolean isInputDeviceEnabled(int deviceId); void enableInputDevice(int deviceId); void disableInputDevice(int deviceId); // Reports whether the hardware supports the given keys; returns true if successful boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists); Loading core/java/android/hardware/input/InputManager.java +56 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,62 @@ public final class InputManager { } } /** * Returns true if an input device is enabled. Should return true for most * situations. Some system apps may disable an input device, for * example to prevent unwanted touch events. * * @param id The input device Id. * * @hide */ public boolean isInputDeviceEnabled(int id) { try { return mIm.isInputDeviceEnabled(id); } catch (RemoteException ex) { Log.w(TAG, "Could not check enabled status of input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Enables an InputDevice. * <p> * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}. * </p> * * @param id The input device Id. * * @hide */ public void enableInputDevice(int id) { try { mIm.enableInputDevice(id); } catch (RemoteException ex) { Log.w(TAG, "Could not enable input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Disables an InputDevice. * <p> * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}. * </p> * * @param id The input device Id. * * @hide */ public void disableInputDevice(int id) { try { mIm.disableInputDevice(id); } catch (RemoteException ex) { Log.w(TAG, "Could not disable input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Registers an input device listener to receive notifications about when * input devices are added, removed or changed. Loading core/java/android/view/InputDevice.java +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.view; import android.annotation.RequiresPermission; import android.annotation.TestApi; import android.content.Context; import android.hardware.input.InputDeviceIdentifier; import android.hardware.input.InputManager; Loading Loading @@ -767,6 +769,38 @@ public final class InputDevice implements Parcelable { } } /** * Returns true if input device is enabled. * @return Whether the input device is enabled. * * @hide */ public boolean isEnabled() { return InputManager.getInstance().isInputDeviceEnabled(mId); } /** * Enables the input device. * * @hide */ @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void enable() { InputManager.getInstance().enableInputDevice(mId); } /** * Disables the input device. * * @hide */ @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void disable() { InputManager.getInstance().disableInputDevice(mId); } /** * Reports whether the device has a built-in microphone. * @return Whether the device has a built-in microphone. Loading core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -2734,6 +2734,13 @@ <permission android:name="android.permission.ACCESS_INPUT_FLINGER" android:protectionLevel="signature" /> <!-- Allows an application to disable/enable input devices. Could be used to prevent unwanted touch events on a touchscreen, for example during swimming or rain. @hide --> <permission android:name="android.permission.DISABLE_INPUT_DEVICE" android:protectionLevel="signature" /> <!-- Allows an application to configure and connect to Wifi displays @hide --> <permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" Loading services/core/java/com/android/server/input/InputManagerService.java +29 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,9 @@ public class InputManagerService extends IInputManager.Stub private static native void nativeReloadDeviceAliases(long ptr); private static native String nativeDump(long ptr); private static native void nativeMonitor(long ptr); private static native boolean nativeIsInputDeviceEnabled(long ptr, int deviceId); private static native void nativeEnableInputDevice(long ptr, int deviceId); private static native void nativeDisableInputDevice(long ptr, int deviceId); private static native void nativeSetPointerIconType(long ptr, int iconId); private static native void nativeReloadPointerIcons(long ptr); private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon); Loading Loading @@ -650,6 +653,32 @@ public class InputManagerService extends IInputManager.Stub return null; } // Binder call @Override public boolean isInputDeviceEnabled(int deviceId) { return nativeIsInputDeviceEnabled(mPtr, deviceId); } // Binder call @Override public void enableInputDevice(int deviceId) { if (!checkCallingPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE, "enableInputDevice()")) { throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission"); } nativeEnableInputDevice(mPtr, deviceId); } // Binder call @Override public void disableInputDevice(int deviceId) { if (!checkCallingPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE, "disableInputDevice()")) { throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission"); } nativeDisableInputDevice(mPtr, deviceId); } /** * Gets the ids of all input devices in the system. * @return The input device ids. Loading Loading
core/java/android/hardware/input/IInputManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ interface IInputManager { InputDevice getInputDevice(int deviceId); int[] getInputDeviceIds(); // Enable/disable input device. boolean isInputDeviceEnabled(int deviceId); void enableInputDevice(int deviceId); void disableInputDevice(int deviceId); // Reports whether the hardware supports the given keys; returns true if successful boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists); Loading
core/java/android/hardware/input/InputManager.java +56 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,62 @@ public final class InputManager { } } /** * Returns true if an input device is enabled. Should return true for most * situations. Some system apps may disable an input device, for * example to prevent unwanted touch events. * * @param id The input device Id. * * @hide */ public boolean isInputDeviceEnabled(int id) { try { return mIm.isInputDeviceEnabled(id); } catch (RemoteException ex) { Log.w(TAG, "Could not check enabled status of input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Enables an InputDevice. * <p> * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}. * </p> * * @param id The input device Id. * * @hide */ public void enableInputDevice(int id) { try { mIm.enableInputDevice(id); } catch (RemoteException ex) { Log.w(TAG, "Could not enable input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Disables an InputDevice. * <p> * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}. * </p> * * @param id The input device Id. * * @hide */ public void disableInputDevice(int id) { try { mIm.disableInputDevice(id); } catch (RemoteException ex) { Log.w(TAG, "Could not disable input device with id = " + id); throw ex.rethrowFromSystemServer(); } } /** * Registers an input device listener to receive notifications about when * input devices are added, removed or changed. Loading
core/java/android/view/InputDevice.java +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.view; import android.annotation.RequiresPermission; import android.annotation.TestApi; import android.content.Context; import android.hardware.input.InputDeviceIdentifier; import android.hardware.input.InputManager; Loading Loading @@ -767,6 +769,38 @@ public final class InputDevice implements Parcelable { } } /** * Returns true if input device is enabled. * @return Whether the input device is enabled. * * @hide */ public boolean isEnabled() { return InputManager.getInstance().isInputDeviceEnabled(mId); } /** * Enables the input device. * * @hide */ @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void enable() { InputManager.getInstance().enableInputDevice(mId); } /** * Disables the input device. * * @hide */ @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void disable() { InputManager.getInstance().disableInputDevice(mId); } /** * Reports whether the device has a built-in microphone. * @return Whether the device has a built-in microphone. Loading
core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -2734,6 +2734,13 @@ <permission android:name="android.permission.ACCESS_INPUT_FLINGER" android:protectionLevel="signature" /> <!-- Allows an application to disable/enable input devices. Could be used to prevent unwanted touch events on a touchscreen, for example during swimming or rain. @hide --> <permission android:name="android.permission.DISABLE_INPUT_DEVICE" android:protectionLevel="signature" /> <!-- Allows an application to configure and connect to Wifi displays @hide --> <permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" Loading
services/core/java/com/android/server/input/InputManagerService.java +29 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,9 @@ public class InputManagerService extends IInputManager.Stub private static native void nativeReloadDeviceAliases(long ptr); private static native String nativeDump(long ptr); private static native void nativeMonitor(long ptr); private static native boolean nativeIsInputDeviceEnabled(long ptr, int deviceId); private static native void nativeEnableInputDevice(long ptr, int deviceId); private static native void nativeDisableInputDevice(long ptr, int deviceId); private static native void nativeSetPointerIconType(long ptr, int iconId); private static native void nativeReloadPointerIcons(long ptr); private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon); Loading Loading @@ -650,6 +653,32 @@ public class InputManagerService extends IInputManager.Stub return null; } // Binder call @Override public boolean isInputDeviceEnabled(int deviceId) { return nativeIsInputDeviceEnabled(mPtr, deviceId); } // Binder call @Override public void enableInputDevice(int deviceId) { if (!checkCallingPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE, "enableInputDevice()")) { throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission"); } nativeEnableInputDevice(mPtr, deviceId); } // Binder call @Override public void disableInputDevice(int deviceId) { if (!checkCallingPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE, "disableInputDevice()")) { throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission"); } nativeDisableInputDevice(mPtr, deviceId); } /** * Gets the ids of all input devices in the system. * @return The input device ids. Loading