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