Loading core/java/android/app/Instrumentation.java +4 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.hardware.input.InputManager; import android.hardware.input.InputManagerGlobal; import android.net.Uri; import android.os.Build; import android.os.Bundle; Loading Loading @@ -1130,7 +1131,7 @@ public class Instrumentation { newEvent.setFlags(event.getFlags() | KeyEvent.FLAG_FROM_SYSTEM); setDisplayIfNeeded(newEvent); InputManager.getInstance().injectInputEvent(newEvent, InputManagerGlobal.getInstance().injectInputEvent(newEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } Loading Loading @@ -1229,7 +1230,7 @@ public class Instrumentation { } // Direct the injected event into windows owned by the instrumentation target. InputManager.getInstance().injectInputEvent( InputManagerGlobal.getInstance().injectInputEvent( event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH, Process.myUid()); if (syncAfter) { Loading Loading @@ -1259,7 +1260,7 @@ public class Instrumentation { if (!event.isFromSource(InputDevice.SOURCE_CLASS_TRACKBALL)) { event.setSource(InputDevice.SOURCE_TRACKBALL); } InputManager.getInstance().injectInputEvent(event, InputManagerGlobal.getInstance().injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } Loading core/java/android/hardware/input/InputManager.java +18 −93 Original line number Diff line number Diff line Loading @@ -34,12 +34,10 @@ import android.content.Context; import android.hardware.BatteryState; import android.hardware.SensorManager; import android.hardware.lights.LightsManager; import android.os.Binder; import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.InputEventInjectionSync; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.Vibrator; Loading Loading @@ -392,12 +390,7 @@ public final class InputManager { * @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(); } return mGlobal.isInputDeviceEnabled(id); } /** Loading @@ -411,12 +404,7 @@ public final class InputManager { * @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(); } mGlobal.enableInputDevice(id); } /** Loading @@ -430,12 +418,7 @@ public final class InputManager { * @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(); } mGlobal.disableInputDevice(id); } /** Loading Loading @@ -1007,13 +990,7 @@ public final class InputManager { * @hide */ public boolean[] deviceHasKeys(int id, int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; try { mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return ret; return mGlobal.deviceHasKeys(id, keyCodes); } /** Loading @@ -1038,11 +1015,7 @@ public final class InputManager { * @hide */ public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) { try { return mIm.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return mGlobal.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } /** Loading Loading @@ -1075,20 +1048,7 @@ public final class InputManager { */ @RequiresPermission(Manifest.permission.INJECT_EVENTS) public boolean injectInputEvent(InputEvent event, int mode, int targetUid) { if (event == null) { throw new IllegalArgumentException("event must not be null"); } if (mode != InputEventInjectionSync.NONE && mode != InputEventInjectionSync.WAIT_FOR_FINISHED && mode != InputEventInjectionSync.WAIT_FOR_RESULT) { throw new IllegalArgumentException("mode is invalid"); } try { return mIm.injectInputEventToTarget(event, mode, targetUid); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } return mGlobal.injectInputEvent(event, mode, targetUid); } /** Loading @@ -1114,7 +1074,7 @@ public final class InputManager { @RequiresPermission(Manifest.permission.INJECT_EVENTS) @UnsupportedAppUsage public boolean injectInputEvent(InputEvent event, int mode) { return injectInputEvent(event, mode, Process.INVALID_UID); return mGlobal.injectInputEvent(event, mode); } /** Loading Loading @@ -1149,20 +1109,12 @@ public final class InputManager { */ @UnsupportedAppUsage public void setPointerIconType(int iconId) { try { mIm.setPointerIconType(iconId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.setPointerIconType(iconId); } /** @hide */ public void setCustomPointerIcon(PointerIcon icon) { try { mIm.setCustomPointerIcon(icon); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.setCustomPointerIcon(icon); } /** Loading Loading @@ -1191,11 +1143,7 @@ public final class InputManager { * @hide */ public void requestPointerCapture(IBinder windowToken, boolean enable) { try { mIm.requestPointerCapture(windowToken, enable); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.requestPointerCapture(windowToken, enable); } /** Loading @@ -1204,11 +1152,7 @@ public final class InputManager { * @hide */ public InputMonitor monitorGestureInput(String name, int displayId) { try { return mIm.monitorGestureInput(new Binder(), name, displayId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } return mGlobal.monitorGestureInput(name, displayId); } /** Loading Loading @@ -1313,12 +1257,9 @@ public final class InputManager { * @hide */ @TestApi public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { try { mIm.addUniqueIdAssociation(inputPort, displayUniqueId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { mGlobal.addUniqueIdAssociation(inputPort, displayUniqueId); } /** Loading @@ -1331,11 +1272,7 @@ public final class InputManager { */ @TestApi public void removeUniqueIdAssociation(@NonNull String inputPort) { try { mIm.removeUniqueIdAssociation(inputPort); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.removeUniqueIdAssociation(inputPort); } /** Loading @@ -1361,11 +1298,7 @@ public final class InputManager { @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getInputDeviceBluetoothAddress(int deviceId) { try { return mIm.getInputDeviceBluetoothAddress(deviceId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return mGlobal.getInputDeviceBluetoothAddress(deviceId); } /** Loading Loading @@ -1423,11 +1356,7 @@ public final class InputManager { * @hide */ public void cancelCurrentTouch() { try { mIm.cancelCurrentTouch(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.cancelCurrentTouch(); } /** Loading @@ -1451,11 +1380,7 @@ public final class InputManager { */ @RequiresPermission(Manifest.permission.MONITOR_INPUT) public void pilferPointers(IBinder inputChannelToken) { try { mIm.pilferPointers(inputChannelToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.pilferPointers(inputChannelToken); } /** Loading core/java/android/hardware/input/InputManagerGlobal.java +215 −2 Original line number Diff line number Diff line Loading @@ -30,19 +30,27 @@ import android.hardware.input.InputManager.OnTabletModeChangedListener; import android.hardware.lights.Light; import android.hardware.lights.LightState; import android.hardware.lights.LightsRequest; import android.os.Binder; import android.os.CombinedVibration; import android.os.Handler; import android.os.IBinder; import android.os.IVibratorStateListener; import android.os.InputEventInjectionSync; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorManager; import android.util.Log; import android.util.SparseArray; import android.view.Display; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputMonitor; import android.view.PointerIcon; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.SomeArgs; Loading Loading @@ -358,6 +366,42 @@ public final class InputManagerGlobal { } } /** * @see InputManager#isInputDeviceEnabled(int) */ 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(); } } /** * @see InputManager#enableInputDevice(int) */ 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(); } } /** * @see InputManager#disableInputDevice(int) */ 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(); } } /** * @see InputManager#getInputDeviceByDescriptor */ Loading Loading @@ -672,7 +716,7 @@ public final class InputManagerGlobal { * @see InputManager#getInputDeviceBatteryState(int, boolean) */ @NonNull BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) { public BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) { if (!hasBattery) { return new LocalBatteryState(); } Loading Loading @@ -835,7 +879,7 @@ public final class InputManagerGlobal { * @see InputManager#getInputDeviceSensorManager(int) */ @NonNull SensorManager getInputDeviceSensorManager(int deviceId) { public SensorManager getInputDeviceSensorManager(int deviceId) { if (mInputDeviceSensorManager == null) { mInputDeviceSensorManager = new InputDeviceSensorManager(this); } Loading Loading @@ -980,6 +1024,21 @@ public final class InputManagerGlobal { } } /** * @see InputManager#getInputDeviceVibrator(int, int) */ public Vibrator getInputDeviceVibrator(int deviceId, int vibratorId) { return new InputDeviceVibrator(deviceId, vibratorId); } /** * @see InputManager#getInputDeviceVibratorManager(int) */ @NonNull public VibratorManager getInputDeviceVibratorManager(int deviceId) { return new InputDeviceVibratorManager(deviceId); } /* * Get the list of device vibrators * @return The list of vibrators IDs Loading Loading @@ -1057,4 +1116,158 @@ public final class InputManagerGlobal { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#deviceHasKeys(int, int[]) */ public boolean[] deviceHasKeys(int id, int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; try { mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return ret; } /** * @see InputManager#getKeyCodeforKeyLocation(int, int) */ public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) { try { return mIm.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#injectInputEvent(InputEvent, int, int) */ public boolean injectInputEvent(InputEvent event, int mode, int targetUid) { if (event == null) { throw new IllegalArgumentException("event must not be null"); } if (mode != InputEventInjectionSync.NONE && mode != InputEventInjectionSync.WAIT_FOR_FINISHED && mode != InputEventInjectionSync.WAIT_FOR_RESULT) { throw new IllegalArgumentException("mode is invalid"); } try { return mIm.injectInputEventToTarget(event, mode, targetUid); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#injectInputEvent(InputEvent, int) */ public boolean injectInputEvent(InputEvent event, int mode) { return injectInputEvent(event, mode, Process.INVALID_UID); } /** * @see InputManager#setPointerIconType(int) */ public void setPointerIconType(int iconId) { try { mIm.setPointerIconType(iconId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#setCustomPointerIcon(PointerIcon) */ public void setCustomPointerIcon(PointerIcon icon) { try { mIm.setCustomPointerIcon(icon); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#requestPointerCapture(IBinder, boolean) */ void requestPointerCapture(IBinder windowToken, boolean enable) { try { mIm.requestPointerCapture(windowToken, enable); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see Inputmanager#monitorGestureInput(String, int) */ InputMonitor monitorGestureInput(String name, int displayId) { try { return mIm.monitorGestureInput(new Binder(), name, displayId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#addUniqueIdAssociation(String, String) */ void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { try { mIm.addUniqueIdAssociation(inputPort, displayUniqueId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#removeUniqueIdAssociation(String) */ public void removeUniqueIdAssociation(@NonNull String inputPort) { try { mIm.removeUniqueIdAssociation(inputPort); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#getInputDeviceBluetoothAddress(int) */ @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getInputDeviceBluetoothAddress(int deviceId) { try { return mIm.getInputDeviceBluetoothAddress(deviceId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#cancelCurrentTouch() */ void cancelCurrentTouch() { try { mIm.cancelCurrentTouch(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#pilferPointers(IBinder) */ @RequiresPermission(Manifest.permission.MONITOR_INPUT) void pilferPointers(IBinder inputChannelToken) { try { mIm.pilferPointers(inputChannelToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } core/java/android/view/InputDevice.java +23 −16 Original line number Diff line number Diff line Loading @@ -776,7 +776,7 @@ public final class InputDevice implements Parcelable { * Each gamepad or joystick is given a unique, positive controller number when initially * configured by the system. This number may change due to events such as device disconnects / * reconnects or user initiated reassignment. Any change in number will trigger an event that * can be observed by registering an {@link InputManager.InputDeviceListener}. * can be observed by registering an {@link InputManagerGlobal.InputDeviceListener}. * </p> * <p> * All input devices which are not gamepads or joysticks will be assigned a controller number Loading Loading @@ -981,7 +981,7 @@ public final class InputDevice implements Parcelable { * generating the keycode given by the corresponding value at the same index in the keys array. */ public boolean[] hasKeys(int... keys) { return InputManager.getInstance().deviceHasKeys(mId, keys); return InputManagerGlobal.getInstance().deviceHasKeys(mId, keys); } /** Loading Loading @@ -1028,7 +1028,8 @@ public final class InputDevice implements Parcelable { * {@link InputDevice#SOURCE_KEYBOARD} or the requested mapping cannot be determined. */ public int getKeyCodeForKeyLocation(int locationKeyCode) { return InputManager.getInstance().getKeyCodeForKeyLocation(mId, locationKeyCode); return InputManagerGlobal.getInstance() .getKeyCodeForKeyLocation(mId, locationKeyCode); } /** Loading Loading @@ -1109,9 +1110,11 @@ public final class InputDevice implements Parcelable { @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getBluetoothAddress() { // We query the address via a separate InputManager API instead of pre-populating it in // this class to avoid leaking it to apps that do not have sufficient permissions. return InputManager.getInstance().getInputDeviceBluetoothAddress(mId); // We query the address via a separate InputManagerGlobal API // instead of pre-populating it in this class to avoid // leaking it to apps that do not have sufficient permissions. return InputManagerGlobal.getInstance() .getInputDeviceBluetoothAddress(mId); } /** Loading @@ -1132,7 +1135,8 @@ public final class InputDevice implements Parcelable { synchronized (mMotionRanges) { if (mVibrator == null) { if (mHasVibrator) { mVibrator = InputManager.getInstance().getInputDeviceVibrator(mId, mVibrator = InputManagerGlobal.getInstance() .getInputDeviceVibrator(mId, VIBRATOR_ID_ALL); } else { mVibrator = NullVibrator.getInstance(); Loading @@ -1154,7 +1158,8 @@ public final class InputDevice implements Parcelable { public VibratorManager getVibratorManager() { synchronized (mMotionRanges) { if (mVibratorManager == null) { mVibratorManager = InputManager.getInstance().getInputDeviceVibratorManager(mId); mVibratorManager = InputManagerGlobal.getInstance() .getInputDeviceVibratorManager(mId); } } return mVibratorManager; Loading @@ -1170,7 +1175,8 @@ public final class InputDevice implements Parcelable { */ @NonNull public BatteryState getBatteryState() { return InputManager.getInstance().getInputDeviceBatteryState(mId, mHasBattery); return InputManagerGlobal.getInstance() .getInputDeviceBatteryState(mId, mHasBattery); } /** Loading Loading @@ -1206,7 +1212,8 @@ public final class InputDevice implements Parcelable { public SensorManager getSensorManager() { synchronized (mMotionRanges) { if (mSensorManager == null) { mSensorManager = InputManager.getInstance().getInputDeviceSensorManager(mId); mSensorManager = InputManagerGlobal.getInstance() .getInputDeviceSensorManager(mId); } } return mSensorManager; Loading @@ -1217,7 +1224,7 @@ public final class InputDevice implements Parcelable { * @return Whether the input device is enabled. */ public boolean isEnabled() { return InputManager.getInstance().isInputDeviceEnabled(mId); return InputManagerGlobal.getInstance().isInputDeviceEnabled(mId); } /** Loading @@ -1228,7 +1235,7 @@ public final class InputDevice implements Parcelable { @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void enable() { InputManager.getInstance().enableInputDevice(mId); InputManagerGlobal.getInstance().enableInputDevice(mId); } /** Loading @@ -1239,7 +1246,7 @@ public final class InputDevice implements Parcelable { @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void disable() { InputManager.getInstance().disableInputDevice(mId); InputManagerGlobal.getInstance().disableInputDevice(mId); } /** Loading Loading @@ -1274,7 +1281,7 @@ public final class InputDevice implements Parcelable { * @hide */ public void setPointerType(int pointerType) { InputManager.getInstance().setPointerIconType(pointerType); InputManagerGlobal.getInstance().setPointerIconType(pointerType); } /** Loading @@ -1283,7 +1290,7 @@ public final class InputDevice implements Parcelable { * @hide */ public void setCustomPointerIcon(PointerIcon icon) { InputManager.getInstance().setCustomPointerIcon(icon); InputManagerGlobal.getInstance().setCustomPointerIcon(icon); } /** Loading @@ -1301,7 +1308,7 @@ public final class InputDevice implements Parcelable { * * @return the supported USI version, or null if the device does not support USI * @see <a href="https://universalstylus.org">Universal Stylus Initiative</a> * @see InputManager#getHostUsiVersion(int) * @see InputManagerGlobal#getHostUsiVersion(int) * @hide */ @Nullable Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.hardware.hdmi.HdmiControlManager; import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.IHdmiControlCallback; import android.hardware.input.InputManager; import android.hardware.input.InputManagerGlobal; import android.hardware.tv.cec.V1_0.Result; import android.hardware.tv.cec.V1_0.SendMessageResult; import android.media.AudioManager; Loading Loading @@ -827,7 +828,7 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice { KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_HDMI, null); InputManager.getInstance() InputManagerGlobal.getInstance() .injectInputEvent(keyEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); keyEvent.recycle(); } Loading Loading
core/java/android/app/Instrumentation.java +4 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.hardware.input.InputManager; import android.hardware.input.InputManagerGlobal; import android.net.Uri; import android.os.Build; import android.os.Bundle; Loading Loading @@ -1130,7 +1131,7 @@ public class Instrumentation { newEvent.setFlags(event.getFlags() | KeyEvent.FLAG_FROM_SYSTEM); setDisplayIfNeeded(newEvent); InputManager.getInstance().injectInputEvent(newEvent, InputManagerGlobal.getInstance().injectInputEvent(newEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } Loading Loading @@ -1229,7 +1230,7 @@ public class Instrumentation { } // Direct the injected event into windows owned by the instrumentation target. InputManager.getInstance().injectInputEvent( InputManagerGlobal.getInstance().injectInputEvent( event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH, Process.myUid()); if (syncAfter) { Loading Loading @@ -1259,7 +1260,7 @@ public class Instrumentation { if (!event.isFromSource(InputDevice.SOURCE_CLASS_TRACKBALL)) { event.setSource(InputDevice.SOURCE_TRACKBALL); } InputManager.getInstance().injectInputEvent(event, InputManagerGlobal.getInstance().injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } Loading
core/java/android/hardware/input/InputManager.java +18 −93 Original line number Diff line number Diff line Loading @@ -34,12 +34,10 @@ import android.content.Context; import android.hardware.BatteryState; import android.hardware.SensorManager; import android.hardware.lights.LightsManager; import android.os.Binder; import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.InputEventInjectionSync; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.Vibrator; Loading Loading @@ -392,12 +390,7 @@ public final class InputManager { * @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(); } return mGlobal.isInputDeviceEnabled(id); } /** Loading @@ -411,12 +404,7 @@ public final class InputManager { * @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(); } mGlobal.enableInputDevice(id); } /** Loading @@ -430,12 +418,7 @@ public final class InputManager { * @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(); } mGlobal.disableInputDevice(id); } /** Loading Loading @@ -1007,13 +990,7 @@ public final class InputManager { * @hide */ public boolean[] deviceHasKeys(int id, int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; try { mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return ret; return mGlobal.deviceHasKeys(id, keyCodes); } /** Loading @@ -1038,11 +1015,7 @@ public final class InputManager { * @hide */ public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) { try { return mIm.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return mGlobal.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } /** Loading Loading @@ -1075,20 +1048,7 @@ public final class InputManager { */ @RequiresPermission(Manifest.permission.INJECT_EVENTS) public boolean injectInputEvent(InputEvent event, int mode, int targetUid) { if (event == null) { throw new IllegalArgumentException("event must not be null"); } if (mode != InputEventInjectionSync.NONE && mode != InputEventInjectionSync.WAIT_FOR_FINISHED && mode != InputEventInjectionSync.WAIT_FOR_RESULT) { throw new IllegalArgumentException("mode is invalid"); } try { return mIm.injectInputEventToTarget(event, mode, targetUid); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } return mGlobal.injectInputEvent(event, mode, targetUid); } /** Loading @@ -1114,7 +1074,7 @@ public final class InputManager { @RequiresPermission(Manifest.permission.INJECT_EVENTS) @UnsupportedAppUsage public boolean injectInputEvent(InputEvent event, int mode) { return injectInputEvent(event, mode, Process.INVALID_UID); return mGlobal.injectInputEvent(event, mode); } /** Loading Loading @@ -1149,20 +1109,12 @@ public final class InputManager { */ @UnsupportedAppUsage public void setPointerIconType(int iconId) { try { mIm.setPointerIconType(iconId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.setPointerIconType(iconId); } /** @hide */ public void setCustomPointerIcon(PointerIcon icon) { try { mIm.setCustomPointerIcon(icon); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.setCustomPointerIcon(icon); } /** Loading Loading @@ -1191,11 +1143,7 @@ public final class InputManager { * @hide */ public void requestPointerCapture(IBinder windowToken, boolean enable) { try { mIm.requestPointerCapture(windowToken, enable); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } mGlobal.requestPointerCapture(windowToken, enable); } /** Loading @@ -1204,11 +1152,7 @@ public final class InputManager { * @hide */ public InputMonitor monitorGestureInput(String name, int displayId) { try { return mIm.monitorGestureInput(new Binder(), name, displayId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } return mGlobal.monitorGestureInput(name, displayId); } /** Loading Loading @@ -1313,12 +1257,9 @@ public final class InputManager { * @hide */ @TestApi public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { try { mIm.addUniqueIdAssociation(inputPort, displayUniqueId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { mGlobal.addUniqueIdAssociation(inputPort, displayUniqueId); } /** Loading @@ -1331,11 +1272,7 @@ public final class InputManager { */ @TestApi public void removeUniqueIdAssociation(@NonNull String inputPort) { try { mIm.removeUniqueIdAssociation(inputPort); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.removeUniqueIdAssociation(inputPort); } /** Loading @@ -1361,11 +1298,7 @@ public final class InputManager { @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getInputDeviceBluetoothAddress(int deviceId) { try { return mIm.getInputDeviceBluetoothAddress(deviceId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return mGlobal.getInputDeviceBluetoothAddress(deviceId); } /** Loading Loading @@ -1423,11 +1356,7 @@ public final class InputManager { * @hide */ public void cancelCurrentTouch() { try { mIm.cancelCurrentTouch(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.cancelCurrentTouch(); } /** Loading @@ -1451,11 +1380,7 @@ public final class InputManager { */ @RequiresPermission(Manifest.permission.MONITOR_INPUT) public void pilferPointers(IBinder inputChannelToken) { try { mIm.pilferPointers(inputChannelToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } mGlobal.pilferPointers(inputChannelToken); } /** Loading
core/java/android/hardware/input/InputManagerGlobal.java +215 −2 Original line number Diff line number Diff line Loading @@ -30,19 +30,27 @@ import android.hardware.input.InputManager.OnTabletModeChangedListener; import android.hardware.lights.Light; import android.hardware.lights.LightState; import android.hardware.lights.LightsRequest; import android.os.Binder; import android.os.CombinedVibration; import android.os.Handler; import android.os.IBinder; import android.os.IVibratorStateListener; import android.os.InputEventInjectionSync; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorManager; import android.util.Log; import android.util.SparseArray; import android.view.Display; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputMonitor; import android.view.PointerIcon; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.SomeArgs; Loading Loading @@ -358,6 +366,42 @@ public final class InputManagerGlobal { } } /** * @see InputManager#isInputDeviceEnabled(int) */ 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(); } } /** * @see InputManager#enableInputDevice(int) */ 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(); } } /** * @see InputManager#disableInputDevice(int) */ 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(); } } /** * @see InputManager#getInputDeviceByDescriptor */ Loading Loading @@ -672,7 +716,7 @@ public final class InputManagerGlobal { * @see InputManager#getInputDeviceBatteryState(int, boolean) */ @NonNull BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) { public BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) { if (!hasBattery) { return new LocalBatteryState(); } Loading Loading @@ -835,7 +879,7 @@ public final class InputManagerGlobal { * @see InputManager#getInputDeviceSensorManager(int) */ @NonNull SensorManager getInputDeviceSensorManager(int deviceId) { public SensorManager getInputDeviceSensorManager(int deviceId) { if (mInputDeviceSensorManager == null) { mInputDeviceSensorManager = new InputDeviceSensorManager(this); } Loading Loading @@ -980,6 +1024,21 @@ public final class InputManagerGlobal { } } /** * @see InputManager#getInputDeviceVibrator(int, int) */ public Vibrator getInputDeviceVibrator(int deviceId, int vibratorId) { return new InputDeviceVibrator(deviceId, vibratorId); } /** * @see InputManager#getInputDeviceVibratorManager(int) */ @NonNull public VibratorManager getInputDeviceVibratorManager(int deviceId) { return new InputDeviceVibratorManager(deviceId); } /* * Get the list of device vibrators * @return The list of vibrators IDs Loading Loading @@ -1057,4 +1116,158 @@ public final class InputManagerGlobal { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#deviceHasKeys(int, int[]) */ public boolean[] deviceHasKeys(int id, int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; try { mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return ret; } /** * @see InputManager#getKeyCodeforKeyLocation(int, int) */ public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) { try { return mIm.getKeyCodeForKeyLocation(deviceId, locationKeyCode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#injectInputEvent(InputEvent, int, int) */ public boolean injectInputEvent(InputEvent event, int mode, int targetUid) { if (event == null) { throw new IllegalArgumentException("event must not be null"); } if (mode != InputEventInjectionSync.NONE && mode != InputEventInjectionSync.WAIT_FOR_FINISHED && mode != InputEventInjectionSync.WAIT_FOR_RESULT) { throw new IllegalArgumentException("mode is invalid"); } try { return mIm.injectInputEventToTarget(event, mode, targetUid); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#injectInputEvent(InputEvent, int) */ public boolean injectInputEvent(InputEvent event, int mode) { return injectInputEvent(event, mode, Process.INVALID_UID); } /** * @see InputManager#setPointerIconType(int) */ public void setPointerIconType(int iconId) { try { mIm.setPointerIconType(iconId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#setCustomPointerIcon(PointerIcon) */ public void setCustomPointerIcon(PointerIcon icon) { try { mIm.setCustomPointerIcon(icon); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#requestPointerCapture(IBinder, boolean) */ void requestPointerCapture(IBinder windowToken, boolean enable) { try { mIm.requestPointerCapture(windowToken, enable); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see Inputmanager#monitorGestureInput(String, int) */ InputMonitor monitorGestureInput(String name, int displayId) { try { return mIm.monitorGestureInput(new Binder(), name, displayId); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * @see InputManager#addUniqueIdAssociation(String, String) */ void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) { try { mIm.addUniqueIdAssociation(inputPort, displayUniqueId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#removeUniqueIdAssociation(String) */ public void removeUniqueIdAssociation(@NonNull String inputPort) { try { mIm.removeUniqueIdAssociation(inputPort); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#getInputDeviceBluetoothAddress(int) */ @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getInputDeviceBluetoothAddress(int deviceId) { try { return mIm.getInputDeviceBluetoothAddress(deviceId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#cancelCurrentTouch() */ void cancelCurrentTouch() { try { mIm.cancelCurrentTouch(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @see InputManager#pilferPointers(IBinder) */ @RequiresPermission(Manifest.permission.MONITOR_INPUT) void pilferPointers(IBinder inputChannelToken) { try { mIm.pilferPointers(inputChannelToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } }
core/java/android/view/InputDevice.java +23 −16 Original line number Diff line number Diff line Loading @@ -776,7 +776,7 @@ public final class InputDevice implements Parcelable { * Each gamepad or joystick is given a unique, positive controller number when initially * configured by the system. This number may change due to events such as device disconnects / * reconnects or user initiated reassignment. Any change in number will trigger an event that * can be observed by registering an {@link InputManager.InputDeviceListener}. * can be observed by registering an {@link InputManagerGlobal.InputDeviceListener}. * </p> * <p> * All input devices which are not gamepads or joysticks will be assigned a controller number Loading Loading @@ -981,7 +981,7 @@ public final class InputDevice implements Parcelable { * generating the keycode given by the corresponding value at the same index in the keys array. */ public boolean[] hasKeys(int... keys) { return InputManager.getInstance().deviceHasKeys(mId, keys); return InputManagerGlobal.getInstance().deviceHasKeys(mId, keys); } /** Loading Loading @@ -1028,7 +1028,8 @@ public final class InputDevice implements Parcelable { * {@link InputDevice#SOURCE_KEYBOARD} or the requested mapping cannot be determined. */ public int getKeyCodeForKeyLocation(int locationKeyCode) { return InputManager.getInstance().getKeyCodeForKeyLocation(mId, locationKeyCode); return InputManagerGlobal.getInstance() .getKeyCodeForKeyLocation(mId, locationKeyCode); } /** Loading Loading @@ -1109,9 +1110,11 @@ public final class InputDevice implements Parcelable { @RequiresPermission(Manifest.permission.BLUETOOTH) @Nullable public String getBluetoothAddress() { // We query the address via a separate InputManager API instead of pre-populating it in // this class to avoid leaking it to apps that do not have sufficient permissions. return InputManager.getInstance().getInputDeviceBluetoothAddress(mId); // We query the address via a separate InputManagerGlobal API // instead of pre-populating it in this class to avoid // leaking it to apps that do not have sufficient permissions. return InputManagerGlobal.getInstance() .getInputDeviceBluetoothAddress(mId); } /** Loading @@ -1132,7 +1135,8 @@ public final class InputDevice implements Parcelable { synchronized (mMotionRanges) { if (mVibrator == null) { if (mHasVibrator) { mVibrator = InputManager.getInstance().getInputDeviceVibrator(mId, mVibrator = InputManagerGlobal.getInstance() .getInputDeviceVibrator(mId, VIBRATOR_ID_ALL); } else { mVibrator = NullVibrator.getInstance(); Loading @@ -1154,7 +1158,8 @@ public final class InputDevice implements Parcelable { public VibratorManager getVibratorManager() { synchronized (mMotionRanges) { if (mVibratorManager == null) { mVibratorManager = InputManager.getInstance().getInputDeviceVibratorManager(mId); mVibratorManager = InputManagerGlobal.getInstance() .getInputDeviceVibratorManager(mId); } } return mVibratorManager; Loading @@ -1170,7 +1175,8 @@ public final class InputDevice implements Parcelable { */ @NonNull public BatteryState getBatteryState() { return InputManager.getInstance().getInputDeviceBatteryState(mId, mHasBattery); return InputManagerGlobal.getInstance() .getInputDeviceBatteryState(mId, mHasBattery); } /** Loading Loading @@ -1206,7 +1212,8 @@ public final class InputDevice implements Parcelable { public SensorManager getSensorManager() { synchronized (mMotionRanges) { if (mSensorManager == null) { mSensorManager = InputManager.getInstance().getInputDeviceSensorManager(mId); mSensorManager = InputManagerGlobal.getInstance() .getInputDeviceSensorManager(mId); } } return mSensorManager; Loading @@ -1217,7 +1224,7 @@ public final class InputDevice implements Parcelable { * @return Whether the input device is enabled. */ public boolean isEnabled() { return InputManager.getInstance().isInputDeviceEnabled(mId); return InputManagerGlobal.getInstance().isInputDeviceEnabled(mId); } /** Loading @@ -1228,7 +1235,7 @@ public final class InputDevice implements Parcelable { @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void enable() { InputManager.getInstance().enableInputDevice(mId); InputManagerGlobal.getInstance().enableInputDevice(mId); } /** Loading @@ -1239,7 +1246,7 @@ public final class InputDevice implements Parcelable { @RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE) @TestApi public void disable() { InputManager.getInstance().disableInputDevice(mId); InputManagerGlobal.getInstance().disableInputDevice(mId); } /** Loading Loading @@ -1274,7 +1281,7 @@ public final class InputDevice implements Parcelable { * @hide */ public void setPointerType(int pointerType) { InputManager.getInstance().setPointerIconType(pointerType); InputManagerGlobal.getInstance().setPointerIconType(pointerType); } /** Loading @@ -1283,7 +1290,7 @@ public final class InputDevice implements Parcelable { * @hide */ public void setCustomPointerIcon(PointerIcon icon) { InputManager.getInstance().setCustomPointerIcon(icon); InputManagerGlobal.getInstance().setCustomPointerIcon(icon); } /** Loading @@ -1301,7 +1308,7 @@ public final class InputDevice implements Parcelable { * * @return the supported USI version, or null if the device does not support USI * @see <a href="https://universalstylus.org">Universal Stylus Initiative</a> * @see InputManager#getHostUsiVersion(int) * @see InputManagerGlobal#getHostUsiVersion(int) * @hide */ @Nullable Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.hardware.hdmi.HdmiControlManager; import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.IHdmiControlCallback; import android.hardware.input.InputManager; import android.hardware.input.InputManagerGlobal; import android.hardware.tv.cec.V1_0.Result; import android.hardware.tv.cec.V1_0.SendMessageResult; import android.media.AudioManager; Loading Loading @@ -827,7 +828,7 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice { KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_HDMI, null); InputManager.getInstance() InputManagerGlobal.getInstance() .injectInputEvent(keyEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); keyEvent.recycle(); } Loading