| 1 |
/* |
| 2 |
* Copyright (C) 2012 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package android.hardware.input; |
| 18 |
|
| 19 |
import android.graphics.Rect; |
| 20 |
import android.hardware.input.InputDeviceIdentifier; |
| 21 |
import android.hardware.input.KeyboardLayout; |
| 22 |
import android.hardware.input.IInputDevicesChangedListener; |
| 23 |
import android.hardware.input.IInputDeviceBatteryListener; |
| 24 |
import android.hardware.input.ITabletModeChangedListener; |
| 25 |
import android.hardware.input.TouchCalibration; |
| 26 |
import android.os.CombinedVibration; |
| 27 |
import android.hardware.input.IInputSensorEventListener; |
| 28 |
import android.hardware.input.InputSensorInfo; |
| 29 |
import android.hardware.lights.Light; |
| 30 |
import android.hardware.lights.LightState; |
| 31 |
import android.os.IBinder; |
| 32 |
import android.os.IVibratorStateListener; |
| 33 |
import android.os.VibrationEffect; |
| 34 |
import android.view.InputDevice; |
| 35 |
import android.view.InputEvent; |
| 36 |
import android.view.InputMonitor; |
| 37 |
import android.view.PointerIcon; |
| 38 |
import android.view.VerifiedInputEvent; |
| 39 |
|
| 40 |
/** @hide */ |
| 41 |
interface IInputManager { |
| 42 |
// Gets input device information. |
| 43 |
InputDevice getInputDevice(int deviceId); |
| 44 |
int[] getInputDeviceIds(); |
| 45 |
|
| 46 |
// Enable/disable input device. |
| 47 |
boolean isInputDeviceEnabled(int deviceId); |
| 48 |
void enableInputDevice(int deviceId); |
| 49 |
void disableInputDevice(int deviceId); |
| 50 |
|
| 51 |
// Reports whether the hardware supports the given keys; returns true if successful |
| 52 |
boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists); |
| 53 |
|
| 54 |
// Returns the keyCode produced when pressing the key at the specified location, given the |
| 55 |
// active keyboard layout. |
| 56 |
int getKeyCodeForKeyLocation(int deviceId, in int locationKeyCode); |
| 57 |
|
| 58 |
// Temporarily changes the pointer speed. |
| 59 |
void tryPointerSpeed(int speed); |
| 60 |
|
| 61 |
// Injects an input event into the system. The caller must have the INJECT_EVENTS permssion. |
| 62 |
// This method exists only for compatibility purposes and may be removed in a future release. |
| 63 |
@UnsupportedAppUsage |
| 64 |
boolean injectInputEvent(in InputEvent ev, int mode); |
| 65 |
|
| 66 |
// Injects an input event into the system. The caller must have the INJECT_EVENTS permission. |
| 67 |
// The caller can target windows owned by a certain UID by providing a valid UID, or by |
| 68 |
// providing {@link android.os.Process#INVALID_UID} to target all windows. |
| 69 |
boolean injectInputEventToTarget(in InputEvent ev, int mode, int targetUid); |
| 70 |
|
| 71 |
VerifiedInputEvent verifyInputEvent(in InputEvent ev); |
| 72 |
|
| 73 |
// Calibrate input device position |
| 74 |
TouchCalibration getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation); |
| 75 |
void setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, |
| 76 |
in TouchCalibration calibration); |
| 77 |
|
| 78 |
// Keyboard layouts configuration. |
| 79 |
KeyboardLayout[] getKeyboardLayouts(); |
| 80 |
KeyboardLayout[] getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier); |
| 81 |
KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor); |
| 82 |
String getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier); |
| 83 |
void setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, |
| 84 |
String keyboardLayoutDescriptor); |
| 85 |
String[] getEnabledKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier); |
| 86 |
void addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, |
| 87 |
String keyboardLayoutDescriptor); |
| 88 |
void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, |
| 89 |
String keyboardLayoutDescriptor); |
| 90 |
|
| 91 |
// Registers an input devices changed listener. |
| 92 |
void registerInputDevicesChangedListener(IInputDevicesChangedListener listener); |
| 93 |
|
| 94 |
// Queries whether the device is currently in tablet mode |
| 95 |
int isInTabletMode(); |
| 96 |
// Registers a tablet mode change listener |
| 97 |
void registerTabletModeChangedListener(ITabletModeChangedListener listener); |
| 98 |
|
| 99 |
// Queries whether the device's microphone is muted by switch |
| 100 |
int isMicMuted(); |
| 101 |
|
| 102 |
// Input device vibrator control. |
| 103 |
void vibrate(int deviceId, in VibrationEffect effect, IBinder token); |
| 104 |
void vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token); |
| 105 |
void cancelVibrate(int deviceId, IBinder token); |
| 106 |
int[] getVibratorIds(int deviceId); |
| 107 |
boolean isVibrating(int deviceId); |
| 108 |
boolean registerVibratorStateListener(int deviceId, in IVibratorStateListener listener); |
| 109 |
boolean unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener); |
| 110 |
|
| 111 |
// Input device battery query. |
| 112 |
int getBatteryStatus(int deviceId); |
| 113 |
int getBatteryCapacity(int deviceId); |
| 114 |
|
| 115 |
void setPointerIconType(int typeId); |
| 116 |
void setCustomPointerIcon(in PointerIcon icon); |
| 117 |
|
| 118 |
oneway void requestPointerCapture(IBinder inputChannelToken, boolean enabled); |
| 119 |
|
| 120 |
/** Create an input monitor for gestures. */ |
| 121 |
InputMonitor monitorGestureInput(IBinder token, String name, int displayId); |
| 122 |
|
| 123 |
// Add a runtime association between the input port and the display port. This overrides any |
| 124 |
// static associations. |
| 125 |
void addPortAssociation(in String inputPort, int displayPort); |
| 126 |
// Remove the runtime association between the input port and the display port. Any existing |
| 127 |
// static association for the cleared input port will be restored. |
| 128 |
void removePortAssociation(in String inputPort); |
| 129 |
|
| 130 |
// Add a runtime association between the input device and display. |
| 131 |
void addUniqueIdAssociation(in String inputPort, in String displayUniqueId); |
| 132 |
// Remove the runtime association between the input device and display. |
| 133 |
void removeUniqueIdAssociation(in String inputPort); |
| 134 |
|
| 135 |
InputSensorInfo[] getSensorList(int deviceId); |
| 136 |
|
| 137 |
boolean registerSensorListener(IInputSensorEventListener listener); |
| 138 |
|
| 139 |
void unregisterSensorListener(IInputSensorEventListener listener); |
| 140 |
|
| 141 |
boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs, |
| 142 |
int maxBatchReportLatencyUs); |
| 143 |
|
| 144 |
void disableSensor(int deviceId, int sensorType); |
| 145 |
|
| 146 |
boolean flushSensor(int deviceId, int sensorType); |
| 147 |
|
| 148 |
List<Light> getLights(int deviceId); |
| 149 |
|
| 150 |
LightState getLightState(int deviceId, int lightId); |
| 151 |
|
| 152 |
void setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token); |
| 153 |
|
| 154 |
void openLightSession(int deviceId, String opPkg, in IBinder token); |
| 155 |
|
| 156 |
void closeLightSession(int deviceId, in IBinder token); |
| 157 |
|
| 158 |
void cancelCurrentTouch(); |
| 159 |
|
| 160 |
void registerBatteryListener(int deviceId, IInputDeviceBatteryListener listener); |
| 161 |
|
| 162 |
void unregisterBatteryListener(int deviceId, IInputDeviceBatteryListener listener); |
| 163 |
|
| 164 |
@EnforcePermission("MONITOR_INPUT") |
| 165 |
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " |
| 166 |
+ "android.Manifest.permission.MONITOR_INPUT)") |
| 167 |
void pilferPointers(IBinder inputChannelToken); |
| 168 |
} |