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. getInputDevice(int deviceId)43 InputDevice getInputDevice(int deviceId); getInputDeviceIds()44 int[] getInputDeviceIds(); 45 46 // Enable/disable input device. isInputDeviceEnabled(int deviceId)47 boolean isInputDeviceEnabled(int deviceId); enableInputDevice(int deviceId)48 void enableInputDevice(int deviceId); disableInputDevice(int deviceId)49 void disableInputDevice(int deviceId); 50 51 // Reports whether the hardware supports the given keys; returns true if successful hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists)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. getKeyCodeForKeyLocation(int deviceId, in int locationKeyCode)56 int getKeyCodeForKeyLocation(int deviceId, in int locationKeyCode); 57 58 // Temporarily changes the pointer speed. tryPointerSpeed(int 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 injectInputEvent(in InputEvent ev, int mode)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. injectInputEventToTarget(in InputEvent ev, int mode, int targetUid)69 boolean injectInputEventToTarget(in InputEvent ev, int mode, int targetUid); 70 verifyInputEvent(in InputEvent ev)71 VerifiedInputEvent verifyInputEvent(in InputEvent ev); 72 73 // Calibrate input device position getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation)74 TouchCalibration getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation); setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, in TouchCalibration calibration)75 void setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, 76 in TouchCalibration calibration); 77 78 // Keyboard layouts configuration. getKeyboardLayouts()79 KeyboardLayout[] getKeyboardLayouts(); getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier)80 KeyboardLayout[] getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier); getKeyboardLayout(String keyboardLayoutDescriptor)81 KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor); getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier)82 String getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier); setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)83 void setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, 84 String keyboardLayoutDescriptor); getEnabledKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier)85 String[] getEnabledKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier); addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)86 void addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, 87 String keyboardLayoutDescriptor); removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)88 void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, 89 String keyboardLayoutDescriptor); 90 91 // Registers an input devices changed listener. registerInputDevicesChangedListener(IInputDevicesChangedListener listener)92 void registerInputDevicesChangedListener(IInputDevicesChangedListener listener); 93 94 // Queries whether the device is currently in tablet mode isInTabletMode()95 int isInTabletMode(); 96 // Registers a tablet mode change listener registerTabletModeChangedListener(ITabletModeChangedListener listener)97 void registerTabletModeChangedListener(ITabletModeChangedListener listener); 98 99 // Queries whether the device's microphone is muted by switch isMicMuted()100 int isMicMuted(); 101 102 // Input device vibrator control. vibrate(int deviceId, in VibrationEffect effect, IBinder token)103 void vibrate(int deviceId, in VibrationEffect effect, IBinder token); vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token)104 void vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token); cancelVibrate(int deviceId, IBinder token)105 void cancelVibrate(int deviceId, IBinder token); getVibratorIds(int deviceId)106 int[] getVibratorIds(int deviceId); isVibrating(int deviceId)107 boolean isVibrating(int deviceId); registerVibratorStateListener(int deviceId, in IVibratorStateListener listener)108 boolean registerVibratorStateListener(int deviceId, in IVibratorStateListener listener); unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener)109 boolean unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener); 110 111 // Input device battery query. getBatteryStatus(int deviceId)112 int getBatteryStatus(int deviceId); getBatteryCapacity(int deviceId)113 int getBatteryCapacity(int deviceId); 114 setPointerIconType(int typeId)115 void setPointerIconType(int typeId); setCustomPointerIcon(in PointerIcon icon)116 void setCustomPointerIcon(in PointerIcon icon); 117 requestPointerCapture(IBinder inputChannelToken, boolean enabled)118 oneway void requestPointerCapture(IBinder inputChannelToken, boolean enabled); 119 120 /** Create an input monitor for gestures. */ monitorGestureInput(IBinder token, String name, int displayId)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. addPortAssociation(in String inputPort, int displayPort)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. removePortAssociation(in String inputPort)128 void removePortAssociation(in String inputPort); 129 130 // Add a runtime association between the input device and display. addUniqueIdAssociation(in String inputPort, in String displayUniqueId)131 void addUniqueIdAssociation(in String inputPort, in String displayUniqueId); 132 // Remove the runtime association between the input device and display. removeUniqueIdAssociation(in String inputPort)133 void removeUniqueIdAssociation(in String inputPort); 134 getSensorList(int deviceId)135 InputSensorInfo[] getSensorList(int deviceId); 136 registerSensorListener(IInputSensorEventListener listener)137 boolean registerSensorListener(IInputSensorEventListener listener); 138 unregisterSensorListener(IInputSensorEventListener listener)139 void unregisterSensorListener(IInputSensorEventListener listener); 140 enableSensor(int deviceId, int sensorType, int samplingPeriodUs, int maxBatchReportLatencyUs)141 boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs, 142 int maxBatchReportLatencyUs); 143 disableSensor(int deviceId, int sensorType)144 void disableSensor(int deviceId, int sensorType); 145 flushSensor(int deviceId, int sensorType)146 boolean flushSensor(int deviceId, int sensorType); 147 getLights(int deviceId)148 List<Light> getLights(int deviceId); 149 getLightState(int deviceId, int lightId)150 LightState getLightState(int deviceId, int lightId); 151 setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token)152 void setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token); 153 openLightSession(int deviceId, String opPkg, in IBinder token)154 void openLightSession(int deviceId, String opPkg, in IBinder token); 155 closeLightSession(int deviceId, in IBinder token)156 void closeLightSession(int deviceId, in IBinder token); 157 cancelCurrentTouch()158 void cancelCurrentTouch(); 159 registerBatteryListener(int deviceId, IInputDeviceBatteryListener listener)160 void registerBatteryListener(int deviceId, IInputDeviceBatteryListener listener); 161 unregisterBatteryListener(int deviceId, IInputDeviceBatteryListener listener)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)") pilferPointers(IBinder inputChannelToken)167 void pilferPointers(IBinder inputChannelToken); 168 } 169