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.ITabletModeChangedListener;
24 import android.hardware.input.TouchCalibration;
25 import android.os.CombinedVibration;
26 import android.hardware.input.IInputSensorEventListener;
27 import android.hardware.input.InputSensorInfo;
28 import android.hardware.lights.Light;
29 import android.hardware.lights.LightState;
30 import android.os.IBinder;
31 import android.os.IVibratorStateListener;
32 import android.os.VibrationEffect;
33 import android.view.InputDevice;
34 import android.view.InputEvent;
35 import android.view.InputMonitor;
36 import android.view.PointerIcon;
37 import android.view.VerifiedInputEvent;
38 
39 /** @hide */
40 interface IInputManager {
41     // Gets input device information.
getInputDevice(int deviceId)42     InputDevice getInputDevice(int deviceId);
getInputDeviceIds()43     int[] getInputDeviceIds();
44 
45     // Enable/disable input device.
isInputDeviceEnabled(int deviceId)46     boolean isInputDeviceEnabled(int deviceId);
enableInputDevice(int deviceId)47     void enableInputDevice(int deviceId);
disableInputDevice(int deviceId)48     void disableInputDevice(int deviceId);
49 
50     // Reports whether the hardware supports the given keys; returns true if successful
hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists)51     boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists);
52 
53     // Temporarily changes the pointer speed.
tryPointerSpeed(int speed)54     void tryPointerSpeed(int speed);
55 
56     // Injects an input event into the system.  To inject into windows owned by other
57     // applications, the caller must have the INJECT_EVENTS permission.
58     @UnsupportedAppUsage
injectInputEvent(in InputEvent ev, int mode)59     boolean injectInputEvent(in InputEvent ev, int mode);
60 
verifyInputEvent(in InputEvent ev)61     VerifiedInputEvent verifyInputEvent(in InputEvent ev);
62 
63     // Calibrate input device position
getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation)64     TouchCalibration getTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation);
setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation, in TouchCalibration calibration)65     void setTouchCalibrationForInputDevice(String inputDeviceDescriptor, int rotation,
66             in TouchCalibration calibration);
67 
68     // Keyboard layouts configuration.
getKeyboardLayouts()69     KeyboardLayout[] getKeyboardLayouts();
getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier)70     KeyboardLayout[] getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier);
getKeyboardLayout(String keyboardLayoutDescriptor)71     KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor);
getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier)72     String getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier);
setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)73     void setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
74             String keyboardLayoutDescriptor);
getEnabledKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier)75     String[] getEnabledKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier);
addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)76     void addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
77             String keyboardLayoutDescriptor);
removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor)78     void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
79             String keyboardLayoutDescriptor);
80 
81     // Registers an input devices changed listener.
registerInputDevicesChangedListener(IInputDevicesChangedListener listener)82     void registerInputDevicesChangedListener(IInputDevicesChangedListener listener);
83 
84     // Queries whether the device is currently in tablet mode
isInTabletMode()85     int isInTabletMode();
86     // Registers a tablet mode change listener
registerTabletModeChangedListener(ITabletModeChangedListener listener)87     void registerTabletModeChangedListener(ITabletModeChangedListener listener);
88 
89     // Queries whether the device's microphone is muted by switch
isMicMuted()90     int isMicMuted();
91 
92     // Input device vibrator control.
vibrate(int deviceId, in VibrationEffect effect, IBinder token)93     void vibrate(int deviceId, in VibrationEffect effect, IBinder token);
vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token)94     void vibrateCombined(int deviceId, in CombinedVibration vibration, IBinder token);
cancelVibrate(int deviceId, IBinder token)95     void cancelVibrate(int deviceId, IBinder token);
getVibratorIds(int deviceId)96     int[] getVibratorIds(int deviceId);
isVibrating(int deviceId)97     boolean isVibrating(int deviceId);
registerVibratorStateListener(int deviceId, in IVibratorStateListener listener)98     boolean registerVibratorStateListener(int deviceId, in IVibratorStateListener listener);
unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener)99     boolean unregisterVibratorStateListener(int deviceId, in IVibratorStateListener listener);
100 
101     // Input device battery query.
getBatteryStatus(int deviceId)102     int getBatteryStatus(int deviceId);
getBatteryCapacity(int deviceId)103     int getBatteryCapacity(int deviceId);
104 
setPointerIconType(int typeId)105     void setPointerIconType(int typeId);
setCustomPointerIcon(in PointerIcon icon)106     void setCustomPointerIcon(in PointerIcon icon);
107 
requestPointerCapture(IBinder inputChannelToken, boolean enabled)108     oneway void requestPointerCapture(IBinder inputChannelToken, boolean enabled);
109 
110     /** Create an input monitor for gestures. */
monitorGestureInput(String name, int displayId)111     InputMonitor monitorGestureInput(String name, int displayId);
112 
113     // Add a runtime association between the input port and the display port. This overrides any
114     // static associations.
addPortAssociation(in String inputPort, int displayPort)115     void addPortAssociation(in String inputPort, int displayPort);
116     // Remove the runtime association between the input port and the display port. Any existing
117     // static association for the cleared input port will be restored.
removePortAssociation(in String inputPort)118     void removePortAssociation(in String inputPort);
119 
120     // Add a runtime association between the input device and display.
addUniqueIdAssociation(in String inputDeviceName, in String displayUniqueId)121     void addUniqueIdAssociation(in String inputDeviceName, in String displayUniqueId);
122     // Remove the runtime association between the input device and display.
removeUniqueIdAssociation(in String inputDeviceName)123     void removeUniqueIdAssociation(in String inputDeviceName);
124 
getSensorList(int deviceId)125     InputSensorInfo[] getSensorList(int deviceId);
126 
registerSensorListener(IInputSensorEventListener listener)127     boolean registerSensorListener(IInputSensorEventListener listener);
128 
unregisterSensorListener(IInputSensorEventListener listener)129     void unregisterSensorListener(IInputSensorEventListener listener);
130 
enableSensor(int deviceId, int sensorType, int samplingPeriodUs, int maxBatchReportLatencyUs)131     boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
132                 int maxBatchReportLatencyUs);
133 
disableSensor(int deviceId, int sensorType)134     void disableSensor(int deviceId, int sensorType);
135 
flushSensor(int deviceId, int sensorType)136     boolean flushSensor(int deviceId, int sensorType);
137 
getLights(int deviceId)138     List<Light> getLights(int deviceId);
139 
getLightState(int deviceId, int lightId)140     LightState getLightState(int deviceId, int lightId);
141 
setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token)142     void setLightStates(int deviceId, in int[] lightIds, in LightState[] states, in IBinder token);
143 
openLightSession(int deviceId, String opPkg, in IBinder token)144     void openLightSession(int deviceId, String opPkg, in IBinder token);
145 
closeLightSession(int deviceId, in IBinder token)146     void closeLightSession(int deviceId, in IBinder token);
147 }
148