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.AidlInputGestureData; 21 import android.hardware.input.HostUsiVersion; 22 import android.hardware.input.InputDeviceIdentifier; 23 import android.hardware.input.KeyboardLayout; 24 import android.hardware.input.IInputDevicesChangedListener; 25 import android.hardware.input.IInputDeviceBatteryListener; 26 import android.hardware.input.IInputDeviceBatteryState; 27 import android.hardware.input.IKeyboardBacklightListener; 28 import android.hardware.input.IKeyboardBacklightState; 29 import android.hardware.input.IKeyGestureEventListener; 30 import android.hardware.input.IKeyGestureHandler; 31 import android.hardware.input.IStickyModifierStateListener; 32 import android.hardware.input.ITabletModeChangedListener; 33 import android.hardware.input.KeyboardLayoutSelectionResult; 34 import android.hardware.input.TouchCalibration; 35 import android.os.CombinedVibration; 36 import android.hardware.input.IInputSensorEventListener; 37 import android.hardware.input.IKeyEventActivityListener; 38 import android.hardware.input.InputSensorInfo; 39 import android.hardware.input.KeyGlyphMap; 40 import android.hardware.lights.Light; 41 import android.hardware.lights.LightState; 42 import android.os.IBinder; 43 import android.os.IVibratorStateListener; 44 import android.os.VibrationEffect; 45 import android.view.inputmethod.InputMethodInfo; 46 import android.view.inputmethod.InputMethodSubtype; 47 import android.view.InputDevice; 48 import android.view.InputEvent; 49 import android.view.InputMonitor; 50 import android.view.PointerIcon; 51 import android.view.KeyCharacterMap; 52 import android.view.VerifiedInputEvent; 53 54 /** @hide */ 55 interface IInputManager { 56 // Gets the current VelocityTracker strategy getVelocityTrackerStrategy()57 String getVelocityTrackerStrategy(); 58 // Gets input device information. getInputDevice(int deviceId)59 InputDevice getInputDevice(int deviceId); getInputDeviceIds()60 int[] getInputDeviceIds(); 61 62 // Enable/disable input device. enableInputDevice(int deviceId)63 void enableInputDevice(int deviceId); disableInputDevice(int deviceId)64 void disableInputDevice(int deviceId); 65 66 // Reports whether the hardware supports the given keys; returns true if successful hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists)67 boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists); 68 69 // Returns the keyCode produced when pressing the key at the specified location, given the 70 // active keyboard layout. getKeyCodeForKeyLocation(int deviceId, in int locationKeyCode)71 int getKeyCodeForKeyLocation(int deviceId, in int locationKeyCode); 72 getKeyCharacterMap(String layoutDescriptor)73 KeyCharacterMap getKeyCharacterMap(String layoutDescriptor); 74 75 // Returns the mouse pointer speed. getMousePointerSpeed()76 int getMousePointerSpeed(); 77 78 // Temporarily changes the pointer speed. tryPointerSpeed(int speed)79 void tryPointerSpeed(int speed); 80 81 // Injects an input event into the system. The caller must have the INJECT_EVENTS permssion. 82 // This method exists only for compatibility purposes and may be removed in a future release. 83 @UnsupportedAppUsage injectInputEvent(in InputEvent ev, int mode)84 boolean injectInputEvent(in InputEvent ev, int mode); 85 86 // Injects an input event into the system. The caller must have the INJECT_EVENTS permission. 87 // The caller can target windows owned by a certain UID by providing a valid UID, or by 88 // providing {@link android.os.Process#INVALID_UID} to target all windows. injectInputEventToTarget(in InputEvent ev, int mode, int targetUid)89 boolean injectInputEventToTarget(in InputEvent ev, int mode, int targetUid); 90 verifyInputEvent(in InputEvent ev)91 VerifiedInputEvent verifyInputEvent(in InputEvent ev); 92 93 // Calibrate input device position getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation)94 TouchCalibration getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation); setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, in TouchCalibration calibration)95 void setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, 96 in TouchCalibration calibration); 97 98 // Keyboard layouts configuration. getKeyboardLayouts()99 KeyboardLayout[] getKeyboardLayouts(); 100 getKeyboardLayout(String keyboardLayoutDescriptor)101 KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor); 102 getKeyboardLayoutForInputDevice( in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype)103 KeyboardLayoutSelectionResult getKeyboardLayoutForInputDevice( 104 in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, 105 in InputMethodSubtype imeSubtype); 106 107 @EnforcePermission("SET_KEYBOARD_LAYOUT") 108 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 109 + "android.Manifest.permission.SET_KEYBOARD_LAYOUT)") setKeyboardLayoutOverrideForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)110 void setKeyboardLayoutOverrideForInputDevice(in InputDeviceIdentifier identifier, 111 String keyboardLayoutDescriptor); 112 113 @EnforcePermission("SET_KEYBOARD_LAYOUT") 114 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 115 + "android.Manifest.permission.SET_KEYBOARD_LAYOUT)") setKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor)116 void setKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, 117 in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype, 118 String keyboardLayoutDescriptor); 119 getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype)120 KeyboardLayout[] getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, 121 int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); 122 123 // Modifier key remapping APIs. 124 @EnforcePermission("REMAP_MODIFIER_KEYS") 125 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 126 + "android.Manifest.permission.REMAP_MODIFIER_KEYS)") remapModifierKey(int fromKey, int toKey)127 void remapModifierKey(int fromKey, int toKey); 128 129 @EnforcePermission("REMAP_MODIFIER_KEYS") 130 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 131 + "android.Manifest.permission.REMAP_MODIFIER_KEYS)") clearAllModifierKeyRemappings()132 void clearAllModifierKeyRemappings(); 133 134 @EnforcePermission("REMAP_MODIFIER_KEYS") 135 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 136 + "android.Manifest.permission.REMAP_MODIFIER_KEYS)") getModifierKeyRemapping()137 Map getModifierKeyRemapping(); 138 139 // Registers an input devices changed listener. registerInputDevicesChangedListener(IInputDevicesChangedListener listener)140 void registerInputDevicesChangedListener(IInputDevicesChangedListener listener); 141 142 // Queries whether the device is currently in tablet mode isInTabletMode()143 int isInTabletMode(); 144 // Registers a tablet mode change listener registerTabletModeChangedListener(ITabletModeChangedListener listener)145 void registerTabletModeChangedListener(ITabletModeChangedListener listener); 146 147 // Queries whether the device's microphone is muted by switch isMicMuted()148 int isMicMuted(); 149 150 // Input device vibrator control. vibrate(int deviceId, in VibrationEffect effect, IBinder token)151 void vibrate(int deviceId, in VibrationEffect effect, IBinder token); vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token)152 void vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token); cancelVibrate(int deviceId, IBinder token)153 void cancelVibrate(int deviceId, IBinder token); getVibratorIds(int deviceId)154 int[] getVibratorIds(int deviceId); isVibrating(int deviceId)155 boolean isVibrating(int deviceId); registerVibratorStateListener(int deviceId, in IVibratorStateListener listener)156 boolean registerVibratorStateListener(int deviceId, in IVibratorStateListener listener); unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener)157 boolean unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener); 158 getBatteryState(int deviceId)159 IInputDeviceBatteryState getBatteryState(int deviceId); 160 setPointerIcon(in PointerIcon icon, int displayId, int deviceId, int pointerId, in IBinder inputToken)161 boolean setPointerIcon(in PointerIcon icon, int displayId, int deviceId, int pointerId, 162 in IBinder inputToken); 163 requestPointerCapture(IBinder inputChannelToken, boolean enabled)164 oneway void requestPointerCapture(IBinder inputChannelToken, boolean enabled); 165 166 /** Create an input monitor for gestures. */ monitorGestureInput(IBinder token, String name, int displayId)167 InputMonitor monitorGestureInput(IBinder token, String name, int displayId); 168 169 // Add a runtime association between the input port and the display port. This overrides any 170 // static associations. addPortAssociation(in String inputPort, int displayPort)171 void addPortAssociation(in String inputPort, int displayPort); 172 // Remove the runtime association between the input port and the display port. Any existing 173 // static association for the cleared input port will be restored. removePortAssociation(in String inputPort)174 void removePortAssociation(in String inputPort); 175 176 // Add a runtime association between the input device and display, using device's descriptor. addUniqueIdAssociationByDescriptor(in String inputDeviceDescriptor, in String displayUniqueId)177 void addUniqueIdAssociationByDescriptor(in String inputDeviceDescriptor, 178 in String displayUniqueId); 179 // Remove the runtime association between the input device and display, using device's 180 // descriptor. removeUniqueIdAssociationByDescriptor(in String inputDeviceDescriptor)181 void removeUniqueIdAssociationByDescriptor(in String inputDeviceDescriptor); 182 183 // Add a runtime association between the input device and display, using device's port. addUniqueIdAssociationByPort(in String inputPort, in String displayUniqueId)184 void addUniqueIdAssociationByPort(in String inputPort, in String displayUniqueId); 185 // Remove the runtime association between the input device and display, using device's port. removeUniqueIdAssociationByPort(in String inputPort)186 void removeUniqueIdAssociationByPort(in String inputPort); 187 getSensorList(int deviceId)188 InputSensorInfo[] getSensorList(int deviceId); 189 registerSensorListener(IInputSensorEventListener listener)190 boolean registerSensorListener(IInputSensorEventListener listener); 191 unregisterSensorListener(IInputSensorEventListener listener)192 void unregisterSensorListener(IInputSensorEventListener listener); 193 enableSensor(int deviceId, int sensorType, int samplingPeriodUs, int maxBatchReportLatencyUs)194 boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs, 195 int maxBatchReportLatencyUs); 196 disableSensor(int deviceId, int sensorType)197 void disableSensor(int deviceId, int sensorType); 198 flushSensor(int deviceId, int sensorType)199 boolean flushSensor(int deviceId, int sensorType); 200 getLights(int deviceId)201 List<Light> getLights(int deviceId); 202 getLightState(int deviceId, int lightId)203 LightState getLightState(int deviceId, int lightId); 204 setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token)205 void setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token); 206 openLightSession(int deviceId, String opPkg, in IBinder token)207 void openLightSession(int deviceId, String opPkg, in IBinder token); 208 closeLightSession(int deviceId, in IBinder token)209 void closeLightSession(int deviceId, in IBinder token); 210 cancelCurrentTouch()211 void cancelCurrentTouch(); 212 registerBatteryListener(int deviceId, IInputDeviceBatteryListener listener)213 void registerBatteryListener(int deviceId, IInputDeviceBatteryListener listener); 214 unregisterBatteryListener(int deviceId, IInputDeviceBatteryListener listener)215 void unregisterBatteryListener(int deviceId, IInputDeviceBatteryListener listener); 216 217 @EnforcePermission("LISTEN_FOR_KEY_ACTIVITY") 218 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 219 + "android.Manifest.permission.LISTEN_FOR_KEY_ACTIVITY)") registerKeyEventActivityListener(IKeyEventActivityListener listener)220 boolean registerKeyEventActivityListener(IKeyEventActivityListener listener); 221 222 @EnforcePermission("LISTEN_FOR_KEY_ACTIVITY") 223 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 224 + "android.Manifest.permission.LISTEN_FOR_KEY_ACTIVITY)") unregisterKeyEventActivityListener(IKeyEventActivityListener listener)225 boolean unregisterKeyEventActivityListener(IKeyEventActivityListener listener); 226 227 // Get the bluetooth address of an input device if known, returning null if it either is not 228 // connected via bluetooth or if the address cannot be determined. 229 @EnforcePermission("BLUETOOTH") 230 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 231 + "android.Manifest.permission.BLUETOOTH)") getInputDeviceBluetoothAddress(int deviceId)232 String getInputDeviceBluetoothAddress(int deviceId); 233 234 @EnforcePermission("MONITOR_INPUT") 235 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 236 + "android.Manifest.permission.MONITOR_INPUT)") pilferPointers(IBinder inputChannelToken)237 void pilferPointers(IBinder inputChannelToken); 238 239 @EnforcePermission("MONITOR_KEYBOARD_BACKLIGHT") 240 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 241 + "android.Manifest.permission.MONITOR_KEYBOARD_BACKLIGHT)") registerKeyboardBacklightListener(IKeyboardBacklightListener listener)242 void registerKeyboardBacklightListener(IKeyboardBacklightListener listener); 243 244 @EnforcePermission("MONITOR_KEYBOARD_BACKLIGHT") 245 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 246 + "android.Manifest.permission.MONITOR_KEYBOARD_BACKLIGHT)") unregisterKeyboardBacklightListener(IKeyboardBacklightListener listener)247 void unregisterKeyboardBacklightListener(IKeyboardBacklightListener listener); 248 getHostUsiVersionFromDisplayConfig(int displayId)249 HostUsiVersion getHostUsiVersionFromDisplayConfig(int displayId); 250 251 @EnforcePermission("MONITOR_STICKY_MODIFIER_STATE") 252 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 253 + "android.Manifest.permission.MONITOR_STICKY_MODIFIER_STATE)") registerStickyModifierStateListener(IStickyModifierStateListener listener)254 void registerStickyModifierStateListener(IStickyModifierStateListener listener); 255 256 @EnforcePermission("MONITOR_STICKY_MODIFIER_STATE") 257 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 258 + "android.Manifest.permission.MONITOR_STICKY_MODIFIER_STATE)") unregisterStickyModifierStateListener(IStickyModifierStateListener listener)259 void unregisterStickyModifierStateListener(IStickyModifierStateListener listener); 260 getKeyGlyphMap(int deviceId)261 KeyGlyphMap getKeyGlyphMap(int deviceId); 262 263 @PermissionManuallyEnforced 264 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 265 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") registerKeyGestureEventListener(IKeyGestureEventListener listener)266 void registerKeyGestureEventListener(IKeyGestureEventListener listener); 267 268 @PermissionManuallyEnforced 269 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 270 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") unregisterKeyGestureEventListener(IKeyGestureEventListener listener)271 void unregisterKeyGestureEventListener(IKeyGestureEventListener listener); 272 273 @PermissionManuallyEnforced 274 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 275 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") registerKeyGestureHandler(in int[] keyGesturesToHandle, IKeyGestureHandler handler)276 void registerKeyGestureHandler(in int[] keyGesturesToHandle, IKeyGestureHandler handler); 277 278 @PermissionManuallyEnforced 279 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 280 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") unregisterKeyGestureHandler(IKeyGestureHandler handler)281 void unregisterKeyGestureHandler(IKeyGestureHandler handler); 282 283 @PermissionManuallyEnforced 284 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 285 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") getInputGesture(int userId, in AidlInputGestureData.Trigger trigger)286 AidlInputGestureData getInputGesture(int userId, in AidlInputGestureData.Trigger trigger); 287 288 @PermissionManuallyEnforced 289 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 290 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") addCustomInputGesture(int userId, in AidlInputGestureData data)291 int addCustomInputGesture(int userId, in AidlInputGestureData data); 292 293 @PermissionManuallyEnforced 294 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 295 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") removeCustomInputGesture(int userId, in AidlInputGestureData data)296 int removeCustomInputGesture(int userId, in AidlInputGestureData data); 297 298 @PermissionManuallyEnforced 299 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 300 + "android.Manifest.permission.MANAGE_KEY_GESTURES)") removeAllCustomInputGestures(int userId, int tag)301 void removeAllCustomInputGestures(int userId, int tag); 302 getCustomInputGestures(int userId, int tag)303 AidlInputGestureData[] getCustomInputGestures(int userId, int tag); 304 getAppLaunchBookmarks()305 AidlInputGestureData[] getAppLaunchBookmarks(); 306 resetLockedModifierState()307 void resetLockedModifierState(); 308 } 309