Merge "Move functions to InputManager Global" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
eb97537b62
@@ -28,6 +28,7 @@ import android.content.IntentFilter;
|
|||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
|
import android.hardware.input.InputManagerGlobal;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -1130,7 +1131,7 @@ public class Instrumentation {
|
|||||||
newEvent.setFlags(event.getFlags() | KeyEvent.FLAG_FROM_SYSTEM);
|
newEvent.setFlags(event.getFlags() | KeyEvent.FLAG_FROM_SYSTEM);
|
||||||
setDisplayIfNeeded(newEvent);
|
setDisplayIfNeeded(newEvent);
|
||||||
|
|
||||||
InputManager.getInstance().injectInputEvent(newEvent,
|
InputManagerGlobal.getInstance().injectInputEvent(newEvent,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1229,7 +1230,7 @@ public class Instrumentation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Direct the injected event into windows owned by the instrumentation target.
|
// 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());
|
event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH, Process.myUid());
|
||||||
|
|
||||||
if (syncAfter) {
|
if (syncAfter) {
|
||||||
@@ -1259,7 +1260,7 @@ public class Instrumentation {
|
|||||||
if (!event.isFromSource(InputDevice.SOURCE_CLASS_TRACKBALL)) {
|
if (!event.isFromSource(InputDevice.SOURCE_CLASS_TRACKBALL)) {
|
||||||
event.setSource(InputDevice.SOURCE_TRACKBALL);
|
event.setSource(InputDevice.SOURCE_TRACKBALL);
|
||||||
}
|
}
|
||||||
InputManager.getInstance().injectInputEvent(event,
|
InputManagerGlobal.getInstance().injectInputEvent(event,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,10 @@ import android.content.Context;
|
|||||||
import android.hardware.BatteryState;
|
import android.hardware.BatteryState;
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.hardware.lights.LightsManager;
|
import android.hardware.lights.LightsManager;
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.InputEventInjectionSync;
|
import android.os.InputEventInjectionSync;
|
||||||
import android.os.Process;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
@@ -392,12 +390,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean isInputDeviceEnabled(int id) {
|
public boolean isInputDeviceEnabled(int id) {
|
||||||
try {
|
return mGlobal.isInputDeviceEnabled(id);
|
||||||
return mIm.isInputDeviceEnabled(id);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
Log.w(TAG, "Could not check enabled status of input device with id = " + id);
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,12 +404,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void enableInputDevice(int id) {
|
public void enableInputDevice(int id) {
|
||||||
try {
|
mGlobal.enableInputDevice(id);
|
||||||
mIm.enableInputDevice(id);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
Log.w(TAG, "Could not enable input device with id = " + id);
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -430,12 +418,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void disableInputDevice(int id) {
|
public void disableInputDevice(int id) {
|
||||||
try {
|
mGlobal.disableInputDevice(id);
|
||||||
mIm.disableInputDevice(id);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
Log.w(TAG, "Could not disable input device with id = " + id);
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1007,13 +990,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean[] deviceHasKeys(int id, int[] keyCodes) {
|
public boolean[] deviceHasKeys(int id, int[] keyCodes) {
|
||||||
boolean[] ret = new boolean[keyCodes.length];
|
return mGlobal.deviceHasKeys(id, keyCodes);
|
||||||
try {
|
|
||||||
mIm.hasKeys(id, InputDevice.SOURCE_ANY, keyCodes, ret);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1038,11 +1015,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) {
|
public int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode) {
|
||||||
try {
|
return mGlobal.getKeyCodeForKeyLocation(deviceId, locationKeyCode);
|
||||||
return mIm.getKeyCodeForKeyLocation(deviceId, locationKeyCode);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1075,20 +1048,7 @@ public final class InputManager {
|
|||||||
*/
|
*/
|
||||||
@RequiresPermission(Manifest.permission.INJECT_EVENTS)
|
@RequiresPermission(Manifest.permission.INJECT_EVENTS)
|
||||||
public boolean injectInputEvent(InputEvent event, int mode, int targetUid) {
|
public boolean injectInputEvent(InputEvent event, int mode, int targetUid) {
|
||||||
if (event == null) {
|
return mGlobal.injectInputEvent(event, mode, targetUid);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1114,7 +1074,7 @@ public final class InputManager {
|
|||||||
@RequiresPermission(Manifest.permission.INJECT_EVENTS)
|
@RequiresPermission(Manifest.permission.INJECT_EVENTS)
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public boolean injectInputEvent(InputEvent event, int mode) {
|
public boolean injectInputEvent(InputEvent event, int mode) {
|
||||||
return injectInputEvent(event, mode, Process.INVALID_UID);
|
return mGlobal.injectInputEvent(event, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1149,20 +1109,12 @@ public final class InputManager {
|
|||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public void setPointerIconType(int iconId) {
|
public void setPointerIconType(int iconId) {
|
||||||
try {
|
mGlobal.setPointerIconType(iconId);
|
||||||
mIm.setPointerIconType(iconId);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setCustomPointerIcon(PointerIcon icon) {
|
public void setCustomPointerIcon(PointerIcon icon) {
|
||||||
try {
|
mGlobal.setCustomPointerIcon(icon);
|
||||||
mIm.setCustomPointerIcon(icon);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1191,11 +1143,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void requestPointerCapture(IBinder windowToken, boolean enable) {
|
public void requestPointerCapture(IBinder windowToken, boolean enable) {
|
||||||
try {
|
mGlobal.requestPointerCapture(windowToken, enable);
|
||||||
mIm.requestPointerCapture(windowToken, enable);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1204,11 +1152,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public InputMonitor monitorGestureInput(String name, int displayId) {
|
public InputMonitor monitorGestureInput(String name, int displayId) {
|
||||||
try {
|
return mGlobal.monitorGestureInput(name, displayId);
|
||||||
return mIm.monitorGestureInput(new Binder(), name, displayId);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
throw ex.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1313,12 +1257,9 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) {
|
public void addUniqueIdAssociation(@NonNull String inputPort,
|
||||||
try {
|
@NonNull String displayUniqueId) {
|
||||||
mIm.addUniqueIdAssociation(inputPort, displayUniqueId);
|
mGlobal.addUniqueIdAssociation(inputPort, displayUniqueId);
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1331,11 +1272,7 @@ public final class InputManager {
|
|||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public void removeUniqueIdAssociation(@NonNull String inputPort) {
|
public void removeUniqueIdAssociation(@NonNull String inputPort) {
|
||||||
try {
|
mGlobal.removeUniqueIdAssociation(inputPort);
|
||||||
mIm.removeUniqueIdAssociation(inputPort);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1361,11 +1298,7 @@ public final class InputManager {
|
|||||||
@RequiresPermission(Manifest.permission.BLUETOOTH)
|
@RequiresPermission(Manifest.permission.BLUETOOTH)
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getInputDeviceBluetoothAddress(int deviceId) {
|
public String getInputDeviceBluetoothAddress(int deviceId) {
|
||||||
try {
|
return mGlobal.getInputDeviceBluetoothAddress(deviceId);
|
||||||
return mIm.getInputDeviceBluetoothAddress(deviceId);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1423,11 +1356,7 @@ public final class InputManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void cancelCurrentTouch() {
|
public void cancelCurrentTouch() {
|
||||||
try {
|
mGlobal.cancelCurrentTouch();
|
||||||
mIm.cancelCurrentTouch();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1451,11 +1380,7 @@ public final class InputManager {
|
|||||||
*/
|
*/
|
||||||
@RequiresPermission(Manifest.permission.MONITOR_INPUT)
|
@RequiresPermission(Manifest.permission.MONITOR_INPUT)
|
||||||
public void pilferPointers(IBinder inputChannelToken) {
|
public void pilferPointers(IBinder inputChannelToken) {
|
||||||
try {
|
mGlobal.pilferPointers(inputChannelToken);
|
||||||
mIm.pilferPointers(inputChannelToken);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,19 +30,27 @@ import android.hardware.input.InputManager.OnTabletModeChangedListener;
|
|||||||
import android.hardware.lights.Light;
|
import android.hardware.lights.Light;
|
||||||
import android.hardware.lights.LightState;
|
import android.hardware.lights.LightState;
|
||||||
import android.hardware.lights.LightsRequest;
|
import android.hardware.lights.LightsRequest;
|
||||||
|
import android.os.Binder;
|
||||||
import android.os.CombinedVibration;
|
import android.os.CombinedVibration;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IVibratorStateListener;
|
import android.os.IVibratorStateListener;
|
||||||
|
import android.os.InputEventInjectionSync;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
|
import android.os.Vibrator;
|
||||||
|
import android.os.VibratorManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.InputDevice;
|
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.annotations.GuardedBy;
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
@@ -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
|
* @see InputManager#getInputDeviceByDescriptor
|
||||||
*/
|
*/
|
||||||
@@ -672,7 +716,7 @@ public final class InputManagerGlobal {
|
|||||||
* @see InputManager#getInputDeviceBatteryState(int, boolean)
|
* @see InputManager#getInputDeviceBatteryState(int, boolean)
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) {
|
public BatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) {
|
||||||
if (!hasBattery) {
|
if (!hasBattery) {
|
||||||
return new LocalBatteryState();
|
return new LocalBatteryState();
|
||||||
}
|
}
|
||||||
@@ -835,7 +879,7 @@ public final class InputManagerGlobal {
|
|||||||
* @see InputManager#getInputDeviceSensorManager(int)
|
* @see InputManager#getInputDeviceSensorManager(int)
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
SensorManager getInputDeviceSensorManager(int deviceId) {
|
public SensorManager getInputDeviceSensorManager(int deviceId) {
|
||||||
if (mInputDeviceSensorManager == null) {
|
if (mInputDeviceSensorManager == null) {
|
||||||
mInputDeviceSensorManager = new InputDeviceSensorManager(this);
|
mInputDeviceSensorManager = new InputDeviceSensorManager(this);
|
||||||
}
|
}
|
||||||
@@ -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
|
* Get the list of device vibrators
|
||||||
* @return The list of vibrators IDs
|
* @return The list of vibrators IDs
|
||||||
@@ -1057,4 +1116,158 @@ public final class InputManagerGlobal {
|
|||||||
throw ex.rethrowFromSystemServer();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -776,7 +776,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
* Each gamepad or joystick is given a unique, positive controller number when initially
|
* 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 /
|
* 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
|
* 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>
|
||||||
* <p>
|
* <p>
|
||||||
* All input devices which are not gamepads or joysticks will be assigned a controller number
|
* All input devices which are not gamepads or joysticks will be assigned a controller number
|
||||||
@@ -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.
|
* generating the keycode given by the corresponding value at the same index in the keys array.
|
||||||
*/
|
*/
|
||||||
public boolean[] hasKeys(int... keys) {
|
public boolean[] hasKeys(int... keys) {
|
||||||
return InputManager.getInstance().deviceHasKeys(mId, keys);
|
return InputManagerGlobal.getInstance().deviceHasKeys(mId, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1028,7 +1028,8 @@ public final class InputDevice implements Parcelable {
|
|||||||
* {@link InputDevice#SOURCE_KEYBOARD} or the requested mapping cannot be determined.
|
* {@link InputDevice#SOURCE_KEYBOARD} or the requested mapping cannot be determined.
|
||||||
*/
|
*/
|
||||||
public int getKeyCodeForKeyLocation(int locationKeyCode) {
|
public int getKeyCodeForKeyLocation(int locationKeyCode) {
|
||||||
return InputManager.getInstance().getKeyCodeForKeyLocation(mId, locationKeyCode);
|
return InputManagerGlobal.getInstance()
|
||||||
|
.getKeyCodeForKeyLocation(mId, locationKeyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1109,9 +1110,11 @@ public final class InputDevice implements Parcelable {
|
|||||||
@RequiresPermission(Manifest.permission.BLUETOOTH)
|
@RequiresPermission(Manifest.permission.BLUETOOTH)
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getBluetoothAddress() {
|
public String getBluetoothAddress() {
|
||||||
// We query the address via a separate InputManager API instead of pre-populating it in
|
// We query the address via a separate InputManagerGlobal API
|
||||||
// this class to avoid leaking it to apps that do not have sufficient permissions.
|
// instead of pre-populating it in this class to avoid
|
||||||
return InputManager.getInstance().getInputDeviceBluetoothAddress(mId);
|
// leaking it to apps that do not have sufficient permissions.
|
||||||
|
return InputManagerGlobal.getInstance()
|
||||||
|
.getInputDeviceBluetoothAddress(mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1132,7 +1135,8 @@ public final class InputDevice implements Parcelable {
|
|||||||
synchronized (mMotionRanges) {
|
synchronized (mMotionRanges) {
|
||||||
if (mVibrator == null) {
|
if (mVibrator == null) {
|
||||||
if (mHasVibrator) {
|
if (mHasVibrator) {
|
||||||
mVibrator = InputManager.getInstance().getInputDeviceVibrator(mId,
|
mVibrator = InputManagerGlobal.getInstance()
|
||||||
|
.getInputDeviceVibrator(mId,
|
||||||
VIBRATOR_ID_ALL);
|
VIBRATOR_ID_ALL);
|
||||||
} else {
|
} else {
|
||||||
mVibrator = NullVibrator.getInstance();
|
mVibrator = NullVibrator.getInstance();
|
||||||
@@ -1154,7 +1158,8 @@ public final class InputDevice implements Parcelable {
|
|||||||
public VibratorManager getVibratorManager() {
|
public VibratorManager getVibratorManager() {
|
||||||
synchronized (mMotionRanges) {
|
synchronized (mMotionRanges) {
|
||||||
if (mVibratorManager == null) {
|
if (mVibratorManager == null) {
|
||||||
mVibratorManager = InputManager.getInstance().getInputDeviceVibratorManager(mId);
|
mVibratorManager = InputManagerGlobal.getInstance()
|
||||||
|
.getInputDeviceVibratorManager(mId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mVibratorManager;
|
return mVibratorManager;
|
||||||
@@ -1170,7 +1175,8 @@ public final class InputDevice implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public BatteryState getBatteryState() {
|
public BatteryState getBatteryState() {
|
||||||
return InputManager.getInstance().getInputDeviceBatteryState(mId, mHasBattery);
|
return InputManagerGlobal.getInstance()
|
||||||
|
.getInputDeviceBatteryState(mId, mHasBattery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1206,7 +1212,8 @@ public final class InputDevice implements Parcelable {
|
|||||||
public SensorManager getSensorManager() {
|
public SensorManager getSensorManager() {
|
||||||
synchronized (mMotionRanges) {
|
synchronized (mMotionRanges) {
|
||||||
if (mSensorManager == null) {
|
if (mSensorManager == null) {
|
||||||
mSensorManager = InputManager.getInstance().getInputDeviceSensorManager(mId);
|
mSensorManager = InputManagerGlobal.getInstance()
|
||||||
|
.getInputDeviceSensorManager(mId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mSensorManager;
|
return mSensorManager;
|
||||||
@@ -1217,7 +1224,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
* @return Whether the input device is enabled.
|
* @return Whether the input device is enabled.
|
||||||
*/
|
*/
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return InputManager.getInstance().isInputDeviceEnabled(mId);
|
return InputManagerGlobal.getInstance().isInputDeviceEnabled(mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1228,7 +1235,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
@RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE)
|
@RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE)
|
||||||
@TestApi
|
@TestApi
|
||||||
public void enable() {
|
public void enable() {
|
||||||
InputManager.getInstance().enableInputDevice(mId);
|
InputManagerGlobal.getInstance().enableInputDevice(mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1239,7 +1246,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
@RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE)
|
@RequiresPermission(android.Manifest.permission.DISABLE_INPUT_DEVICE)
|
||||||
@TestApi
|
@TestApi
|
||||||
public void disable() {
|
public void disable() {
|
||||||
InputManager.getInstance().disableInputDevice(mId);
|
InputManagerGlobal.getInstance().disableInputDevice(mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1274,7 +1281,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setPointerType(int pointerType) {
|
public void setPointerType(int pointerType) {
|
||||||
InputManager.getInstance().setPointerIconType(pointerType);
|
InputManagerGlobal.getInstance().setPointerIconType(pointerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1283,7 +1290,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setCustomPointerIcon(PointerIcon icon) {
|
public void setCustomPointerIcon(PointerIcon icon) {
|
||||||
InputManager.getInstance().setCustomPointerIcon(icon);
|
InputManagerGlobal.getInstance().setCustomPointerIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1301,7 +1308,7 @@ public final class InputDevice implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @return the supported USI version, or null if the device does not support USI
|
* @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 <a href="https://universalstylus.org">Universal Stylus Initiative</a>
|
||||||
* @see InputManager#getHostUsiVersion(int)
|
* @see InputManagerGlobal#getHostUsiVersion(int)
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.hardware.hdmi.HdmiControlManager;
|
|||||||
import android.hardware.hdmi.HdmiDeviceInfo;
|
import android.hardware.hdmi.HdmiDeviceInfo;
|
||||||
import android.hardware.hdmi.IHdmiControlCallback;
|
import android.hardware.hdmi.IHdmiControlCallback;
|
||||||
import android.hardware.input.InputManager;
|
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.Result;
|
||||||
import android.hardware.tv.cec.V1_0.SendMessageResult;
|
import android.hardware.tv.cec.V1_0.SendMessageResult;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@@ -827,7 +828,7 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice {
|
|||||||
KeyEvent.FLAG_FROM_SYSTEM,
|
KeyEvent.FLAG_FROM_SYSTEM,
|
||||||
InputDevice.SOURCE_HDMI,
|
InputDevice.SOURCE_HDMI,
|
||||||
null);
|
null);
|
||||||
InputManager.getInstance()
|
InputManagerGlobal.getInstance()
|
||||||
.injectInputEvent(keyEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
.injectInputEvent(keyEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
||||||
keyEvent.recycle();
|
keyEvent.recycle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import static android.view.KeyEvent.META_SHIFT_RIGHT_ON;
|
|||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
|
import android.hardware.input.InputManagerGlobal;
|
||||||
import android.os.ShellCommand;
|
import android.os.ShellCommand;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@@ -109,7 +110,7 @@ public class InputShellCommand extends ShellCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void injectKeyEvent(KeyEvent event) {
|
private void injectKeyEvent(KeyEvent event) {
|
||||||
InputManager.getInstance().injectInputEvent(event,
|
InputManagerGlobal.getInstance().injectInputEvent(event,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ public class InputShellCommand extends ShellCommand {
|
|||||||
pointerProperties, pointerCoords, DEFAULT_META_STATE, DEFAULT_BUTTON_STATE,
|
pointerProperties, pointerCoords, DEFAULT_META_STATE, DEFAULT_BUTTON_STATE,
|
||||||
DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, getInputDeviceId(inputSource),
|
DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, getInputDeviceId(inputSource),
|
||||||
DEFAULT_EDGE_FLAGS, inputSource, displayId, DEFAULT_FLAGS);
|
DEFAULT_EDGE_FLAGS, inputSource, displayId, DEFAULT_FLAGS);
|
||||||
InputManager.getInstance().injectInputEvent(event,
|
InputManagerGlobal.getInstance().injectInputEvent(event,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,7 +531,7 @@ public class InputShellCommand extends ShellCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void injectKeyEventAsync(KeyEvent event) {
|
private void injectKeyEventAsync(KeyEvent event) {
|
||||||
InputManager.getInstance().injectInputEvent(event,
|
InputManagerGlobal.getInstance().injectInputEvent(event,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user