Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 17 | package com.android.server.wm; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 18 | |
| 19 | import com.android.internal.util.XmlUtils; |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 20 | import com.android.server.Watchdog; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 21 | |
| 22 | import org.xmlpull.v1.XmlPullParser; |
| 23 | |
| 24 | import android.content.Context; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 26 | import android.content.res.Configuration; |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 27 | import android.database.ContentObserver; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 28 | import android.os.Environment; |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 29 | import android.os.Looper; |
| 30 | import android.os.MessageQueue; |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 31 | import android.os.SystemProperties; |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 32 | import android.provider.Settings; |
| 33 | import android.provider.Settings.SettingNotFoundException; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 34 | import android.util.Slog; |
| 35 | import android.util.Xml; |
| 36 | import android.view.InputChannel; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 37 | import android.view.InputDevice; |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 38 | import android.view.InputEvent; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 39 | import android.view.KeyEvent; |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 40 | import android.view.PointerIcon; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 41 | import android.view.Surface; |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 42 | import android.view.ViewConfiguration; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 43 | import android.view.WindowManager; |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 44 | import android.view.WindowManagerPolicy; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 45 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 46 | import java.io.File; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 47 | import java.io.FileNotFoundException; |
| 48 | import java.io.FileReader; |
| 49 | import java.io.IOException; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 50 | import java.io.PrintWriter; |
| 51 | import java.util.ArrayList; |
| 52 | |
| 53 | /* |
| 54 | * Wraps the C++ InputManager and provides its callbacks. |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 55 | */ |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 56 | public class InputManager implements Watchdog.Monitor { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 57 | static final String TAG = "InputManager"; |
| 58 | |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 59 | private static final boolean DEBUG = false; |
| 60 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 61 | private final Callbacks mCallbacks; |
| 62 | private final Context mContext; |
| 63 | private final WindowManagerService mWindowManagerService; |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 64 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 65 | private static native void nativeInit(Context context, |
| 66 | Callbacks callbacks, MessageQueue messageQueue); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 67 | private static native void nativeStart(); |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 68 | private static native void nativeSetDisplaySize(int displayId, int width, int height, |
| 69 | int externalWidth, int externalHeight); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 70 | private static native void nativeSetDisplayOrientation(int displayId, int rotation); |
| 71 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 72 | private static native int nativeGetScanCodeState(int deviceId, int sourceMask, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 73 | int scanCode); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 74 | private static native int nativeGetKeyCodeState(int deviceId, int sourceMask, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 75 | int keyCode); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 76 | private static native int nativeGetSwitchState(int deviceId, int sourceMask, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 77 | int sw); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 78 | private static native boolean nativeHasKeys(int deviceId, int sourceMask, |
| 79 | int[] keyCodes, boolean[] keyExists); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 80 | private static native void nativeRegisterInputChannel(InputChannel inputChannel, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 81 | InputWindowHandle inputWindowHandle, boolean monitor); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 82 | private static native void nativeUnregisterInputChannel(InputChannel inputChannel); |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 83 | private static native void nativeSetInputFilterEnabled(boolean enable); |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 84 | private static native int nativeInjectInputEvent(InputEvent event, |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 85 | int injectorPid, int injectorUid, int syncMode, int timeoutMillis, |
| 86 | int policyFlags); |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 87 | private static native void nativeSetInputWindows(InputWindowHandle[] windowHandles); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 88 | private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen); |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 89 | private static native void nativeSetSystemUiVisibility(int visibility); |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 90 | private static native void nativeSetFocusedApplication(InputApplicationHandle application); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 91 | private static native InputDevice nativeGetInputDevice(int deviceId); |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 92 | private static native void nativeGetInputConfiguration(Configuration configuration); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 93 | private static native int[] nativeGetInputDeviceIds(); |
Jeff Brown | e650412 | 2010-09-27 14:52:15 -0700 | [diff] [blame] | 94 | private static native boolean nativeTransferTouchFocus(InputChannel fromChannel, |
| 95 | InputChannel toChannel); |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 96 | private static native void nativeSetPointerSpeed(int speed); |
Jeff Brown | daf4a12 | 2011-08-26 17:14:14 -0700 | [diff] [blame^] | 97 | private static native void nativeSetShowTouches(boolean enabled); |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 98 | private static native String nativeDump(); |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 99 | private static native void nativeMonitor(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 100 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 101 | // Input event injection constants defined in InputDispatcher.h. |
| 102 | static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0; |
| 103 | static final int INPUT_EVENT_INJECTION_PERMISSION_DENIED = 1; |
| 104 | static final int INPUT_EVENT_INJECTION_FAILED = 2; |
| 105 | static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3; |
| 106 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 107 | // Input event injection synchronization modes defined in InputDispatcher.h |
| 108 | static final int INPUT_EVENT_INJECTION_SYNC_NONE = 0; |
| 109 | static final int INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT = 1; |
| 110 | static final int INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH = 2; |
| 111 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 112 | // Key states (may be returned by queries about the current state of a |
| 113 | // particular key code, scan code or switch). |
| 114 | |
| 115 | /** The key state is unknown or the requested key itself is not supported. */ |
| 116 | public static final int KEY_STATE_UNKNOWN = -1; |
| 117 | |
| 118 | /** The key is up. /*/ |
| 119 | public static final int KEY_STATE_UP = 0; |
| 120 | |
| 121 | /** The key is down. */ |
| 122 | public static final int KEY_STATE_DOWN = 1; |
| 123 | |
| 124 | /** The key is down but is a virtual key press that is being emulated by the system. */ |
| 125 | public static final int KEY_STATE_VIRTUAL = 2; |
| 126 | |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 127 | // State for the currently installed input filter. |
| 128 | final Object mInputFilterLock = new Object(); |
| 129 | InputFilter mInputFilter; |
| 130 | InputFilterHost mInputFilterHost; |
| 131 | |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 132 | public InputManager(Context context, WindowManagerService windowManagerService) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 133 | this.mContext = context; |
| 134 | this.mWindowManagerService = windowManagerService; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 135 | this.mCallbacks = new Callbacks(); |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 136 | |
| 137 | Looper looper = windowManagerService.mH.getLooper(); |
| 138 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 139 | Slog.i(TAG, "Initializing input manager"); |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 140 | nativeInit(mContext, mCallbacks, looper.getQueue()); |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 141 | |
| 142 | // Add ourself to the Watchdog monitors. |
| 143 | Watchdog.getInstance().addMonitor(this); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 144 | } |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 145 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 146 | public void start() { |
| 147 | Slog.i(TAG, "Starting input manager"); |
| 148 | nativeStart(); |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 149 | |
| 150 | registerPointerSpeedSettingObserver(); |
Jeff Brown | daf4a12 | 2011-08-26 17:14:14 -0700 | [diff] [blame^] | 151 | registerShowTouchesSettingObserver(); |
| 152 | |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 153 | updatePointerSpeedFromSettings(); |
Jeff Brown | daf4a12 | 2011-08-26 17:14:14 -0700 | [diff] [blame^] | 154 | updateShowTouchesFromSettings(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 157 | public void setDisplaySize(int displayId, int width, int height, |
| 158 | int externalWidth, int externalHeight) { |
| 159 | if (width <= 0 || height <= 0 || externalWidth <= 0 || externalHeight <= 0) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 160 | throw new IllegalArgumentException("Invalid display id or dimensions."); |
| 161 | } |
| 162 | |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 163 | if (DEBUG) { |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 164 | Slog.d(TAG, "Setting display #" + displayId + " size to " + width + "x" + height |
| 165 | + " external size " + externalWidth + "x" + externalHeight); |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 166 | } |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 167 | nativeSetDisplaySize(displayId, width, height, externalWidth, externalHeight); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | public void setDisplayOrientation(int displayId, int rotation) { |
| 171 | if (rotation < Surface.ROTATION_0 || rotation > Surface.ROTATION_270) { |
| 172 | throw new IllegalArgumentException("Invalid rotation."); |
| 173 | } |
| 174 | |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 175 | if (DEBUG) { |
| 176 | Slog.d(TAG, "Setting display #" + displayId + " orientation to " + rotation); |
| 177 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 178 | nativeSetDisplayOrientation(displayId, rotation); |
| 179 | } |
| 180 | |
| 181 | public void getInputConfiguration(Configuration config) { |
| 182 | if (config == null) { |
| 183 | throw new IllegalArgumentException("config must not be null."); |
| 184 | } |
| 185 | |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 186 | nativeGetInputConfiguration(config); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Gets the current state of a key or button by key code. |
| 191 | * @param deviceId The input device id, or -1 to consult all devices. |
| 192 | * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to |
| 193 | * consider all input sources. An input device is consulted if at least one of its |
| 194 | * non-class input source bits matches the specified source mask. |
| 195 | * @param keyCode The key code to check. |
| 196 | * @return The key state. |
| 197 | */ |
| 198 | public int getKeyCodeState(int deviceId, int sourceMask, int keyCode) { |
| 199 | return nativeGetKeyCodeState(deviceId, sourceMask, keyCode); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 202 | /** |
| 203 | * Gets the current state of a key or button by scan code. |
| 204 | * @param deviceId The input device id, or -1 to consult all devices. |
| 205 | * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to |
| 206 | * consider all input sources. An input device is consulted if at least one of its |
| 207 | * non-class input source bits matches the specified source mask. |
| 208 | * @param scanCode The scan code to check. |
| 209 | * @return The key state. |
| 210 | */ |
| 211 | public int getScanCodeState(int deviceId, int sourceMask, int scanCode) { |
| 212 | return nativeGetScanCodeState(deviceId, sourceMask, scanCode); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 215 | /** |
| 216 | * Gets the current state of a switch by switch code. |
| 217 | * @param deviceId The input device id, or -1 to consult all devices. |
| 218 | * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to |
| 219 | * consider all input sources. An input device is consulted if at least one of its |
| 220 | * non-class input source bits matches the specified source mask. |
| 221 | * @param switchCode The switch code to check. |
| 222 | * @return The switch state. |
| 223 | */ |
| 224 | public int getSwitchState(int deviceId, int sourceMask, int switchCode) { |
| 225 | return nativeGetSwitchState(deviceId, sourceMask, switchCode); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 228 | /** |
| 229 | * Determines whether the specified key codes are supported by a particular device. |
| 230 | * @param deviceId The input device id, or -1 to consult all devices. |
| 231 | * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to |
| 232 | * consider all input sources. An input device is consulted if at least one of its |
| 233 | * non-class input source bits matches the specified source mask. |
| 234 | * @param keyCodes The array of key codes to check. |
| 235 | * @param keyExists An array at least as large as keyCodes whose entries will be set |
| 236 | * to true or false based on the presence or absence of support for the corresponding |
| 237 | * key codes. |
| 238 | * @return True if the lookup was successful, false otherwise. |
| 239 | */ |
| 240 | public boolean hasKeys(int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 241 | if (keyCodes == null) { |
| 242 | throw new IllegalArgumentException("keyCodes must not be null."); |
| 243 | } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 244 | if (keyExists == null || keyExists.length < keyCodes.length) { |
| 245 | throw new IllegalArgumentException("keyExists must not be null and must be at " |
| 246 | + "least as large as keyCodes."); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 249 | return nativeHasKeys(deviceId, sourceMask, keyCodes, keyExists); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 252 | /** |
| 253 | * Creates an input channel that will receive all input from the input dispatcher. |
| 254 | * @param inputChannelName The input channel name. |
| 255 | * @return The input channel. |
| 256 | */ |
| 257 | public InputChannel monitorInput(String inputChannelName) { |
| 258 | if (inputChannelName == null) { |
| 259 | throw new IllegalArgumentException("inputChannelName must not be null."); |
| 260 | } |
| 261 | |
| 262 | InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName); |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 263 | nativeRegisterInputChannel(inputChannels[0], null, true); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 264 | inputChannels[0].dispose(); // don't need to retain the Java object reference |
| 265 | return inputChannels[1]; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Registers an input channel so that it can be used as an input event target. |
| 270 | * @param inputChannel The input channel to register. |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 271 | * @param inputWindowHandle The handle of the input window associated with the |
| 272 | * input channel, or null if none. |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 273 | */ |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 274 | public void registerInputChannel(InputChannel inputChannel, |
| 275 | InputWindowHandle inputWindowHandle) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 276 | if (inputChannel == null) { |
| 277 | throw new IllegalArgumentException("inputChannel must not be null."); |
| 278 | } |
| 279 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 280 | nativeRegisterInputChannel(inputChannel, inputWindowHandle, false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 283 | /** |
| 284 | * Unregisters an input channel. |
| 285 | * @param inputChannel The input channel to unregister. |
| 286 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 287 | public void unregisterInputChannel(InputChannel inputChannel) { |
| 288 | if (inputChannel == null) { |
| 289 | throw new IllegalArgumentException("inputChannel must not be null."); |
| 290 | } |
| 291 | |
| 292 | nativeUnregisterInputChannel(inputChannel); |
| 293 | } |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | * Sets an input filter that will receive all input events before they are dispatched. |
| 297 | * The input filter may then reinterpret input events or inject new ones. |
| 298 | * |
| 299 | * To ensure consistency, the input dispatcher automatically drops all events |
| 300 | * in progress whenever an input filter is installed or uninstalled. After an input |
| 301 | * filter is uninstalled, it can no longer send input events unless it is reinstalled. |
| 302 | * Any events it attempts to send after it has been uninstalled will be dropped. |
| 303 | * |
| 304 | * @param filter The input filter, or null to remove the current filter. |
| 305 | */ |
| 306 | public void setInputFilter(InputFilter filter) { |
| 307 | synchronized (mInputFilterLock) { |
| 308 | final InputFilter oldFilter = mInputFilter; |
| 309 | if (oldFilter == filter) { |
| 310 | return; // nothing to do |
| 311 | } |
| 312 | |
| 313 | if (oldFilter != null) { |
| 314 | mInputFilter = null; |
| 315 | mInputFilterHost.disconnectLocked(); |
| 316 | mInputFilterHost = null; |
| 317 | oldFilter.uninstall(); |
| 318 | } |
| 319 | |
| 320 | if (filter != null) { |
| 321 | mInputFilter = filter; |
| 322 | mInputFilterHost = new InputFilterHost(); |
| 323 | filter.install(mInputFilterHost); |
| 324 | } |
| 325 | |
| 326 | nativeSetInputFilterEnabled(filter != null); |
| 327 | } |
| 328 | } |
| 329 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 330 | /** |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 331 | * Injects an input event into the event system on behalf of an application. |
| 332 | * The synchronization mode determines whether the method blocks while waiting for |
| 333 | * input injection to proceed. |
| 334 | * |
| 335 | * {@link #INPUT_EVENT_INJECTION_SYNC_NONE} never blocks. Injection is asynchronous and |
| 336 | * is assumed always to be successful. |
| 337 | * |
| 338 | * {@link #INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT} waits for previous events to be |
| 339 | * dispatched so that the input dispatcher can determine whether input event injection will |
| 340 | * be permitted based on the current input focus. Does not wait for the input event to |
| 341 | * finish processing. |
| 342 | * |
| 343 | * {@link #INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH} waits for the input event to |
| 344 | * be completely processed. |
| 345 | * |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 346 | * @param event The event to inject. |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 347 | * @param injectorPid The pid of the injecting application. |
| 348 | * @param injectorUid The uid of the injecting application. |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 349 | * @param syncMode The synchronization mode. |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 350 | * @param timeoutMillis The injection timeout in milliseconds. |
| 351 | * @return One of the INPUT_EVENT_INJECTION_XXX constants. |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 352 | */ |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 353 | public int injectInputEvent(InputEvent event, int injectorPid, int injectorUid, |
| 354 | int syncMode, int timeoutMillis) { |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 355 | if (event == null) { |
| 356 | throw new IllegalArgumentException("event must not be null"); |
| 357 | } |
| 358 | if (injectorPid < 0 || injectorUid < 0) { |
| 359 | throw new IllegalArgumentException("injectorPid and injectorUid must not be negative."); |
| 360 | } |
| 361 | if (timeoutMillis <= 0) { |
| 362 | throw new IllegalArgumentException("timeoutMillis must be positive"); |
| 363 | } |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 364 | |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 365 | return nativeInjectInputEvent(event, injectorPid, injectorUid, syncMode, timeoutMillis, |
| 366 | WindowManagerPolicy.FLAG_DISABLE_KEY_REPEAT); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 367 | } |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 368 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 369 | /** |
| 370 | * Gets information about the input device with the specified id. |
| 371 | * @param id The device id. |
| 372 | * @return The input device or null if not found. |
| 373 | */ |
| 374 | public InputDevice getInputDevice(int deviceId) { |
| 375 | return nativeGetInputDevice(deviceId); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Gets the ids of all input devices in the system. |
| 380 | * @return The input device ids. |
| 381 | */ |
| 382 | public int[] getInputDeviceIds() { |
| 383 | return nativeGetInputDeviceIds(); |
| 384 | } |
| 385 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 386 | public void setInputWindows(InputWindowHandle[] windowHandles) { |
| 387 | nativeSetInputWindows(windowHandles); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 390 | public void setFocusedApplication(InputApplicationHandle application) { |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 391 | nativeSetFocusedApplication(application); |
| 392 | } |
| 393 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 394 | public void setInputDispatchMode(boolean enabled, boolean frozen) { |
| 395 | nativeSetInputDispatchMode(enabled, frozen); |
| 396 | } |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 397 | |
| 398 | public void setSystemUiVisibility(int visibility) { |
| 399 | nativeSetSystemUiVisibility(visibility); |
| 400 | } |
| 401 | |
Jeff Brown | e650412 | 2010-09-27 14:52:15 -0700 | [diff] [blame] | 402 | /** |
| 403 | * Atomically transfers touch focus from one window to another as identified by |
| 404 | * their input channels. It is possible for multiple windows to have |
| 405 | * touch focus if they support split touch dispatch |
| 406 | * {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} but this |
| 407 | * method only transfers touch focus of the specified window without affecting |
| 408 | * other windows that may also have touch focus at the same time. |
| 409 | * @param fromChannel The channel of a window that currently has touch focus. |
| 410 | * @param toChannel The channel of the window that should receive touch focus in |
| 411 | * place of the first. |
| 412 | * @return True if the transfer was successful. False if the window with the |
| 413 | * specified channel did not actually have touch focus at the time of the request. |
| 414 | */ |
| 415 | public boolean transferTouchFocus(InputChannel fromChannel, InputChannel toChannel) { |
| 416 | if (fromChannel == null) { |
| 417 | throw new IllegalArgumentException("fromChannel must not be null."); |
| 418 | } |
| 419 | if (toChannel == null) { |
| 420 | throw new IllegalArgumentException("toChannel must not be null."); |
| 421 | } |
| 422 | return nativeTransferTouchFocus(fromChannel, toChannel); |
| 423 | } |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 424 | |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 425 | /** |
| 426 | * Set the pointer speed. |
| 427 | * @param speed The pointer speed as a value between -7 (slowest) and 7 (fastest) |
| 428 | * where 0 is the default speed. |
| 429 | */ |
| 430 | public void setPointerSpeed(int speed) { |
| 431 | speed = Math.min(Math.max(speed, -7), 7); |
| 432 | nativeSetPointerSpeed(speed); |
| 433 | } |
| 434 | |
| 435 | public void updatePointerSpeedFromSettings() { |
| 436 | int speed = getPointerSpeedSetting(0); |
| 437 | setPointerSpeed(speed); |
| 438 | } |
| 439 | |
| 440 | private void registerPointerSpeedSettingObserver() { |
| 441 | mContext.getContentResolver().registerContentObserver( |
| 442 | Settings.System.getUriFor(Settings.System.POINTER_SPEED), true, |
| 443 | new ContentObserver(mWindowManagerService.mH) { |
| 444 | @Override |
| 445 | public void onChange(boolean selfChange) { |
| 446 | updatePointerSpeedFromSettings(); |
| 447 | } |
| 448 | }); |
| 449 | } |
| 450 | |
| 451 | private int getPointerSpeedSetting(int defaultValue) { |
| 452 | int speed = defaultValue; |
| 453 | try { |
| 454 | speed = Settings.System.getInt(mContext.getContentResolver(), |
| 455 | Settings.System.POINTER_SPEED); |
| 456 | } catch (SettingNotFoundException snfe) { |
| 457 | } |
| 458 | return speed; |
| 459 | } |
| 460 | |
Jeff Brown | daf4a12 | 2011-08-26 17:14:14 -0700 | [diff] [blame^] | 461 | public void updateShowTouchesFromSettings() { |
| 462 | int setting = getShowTouchesSetting(0); |
| 463 | nativeSetShowTouches(setting != 0); |
| 464 | } |
| 465 | |
| 466 | private void registerShowTouchesSettingObserver() { |
| 467 | mContext.getContentResolver().registerContentObserver( |
| 468 | Settings.System.getUriFor(Settings.System.SHOW_TOUCHES), true, |
| 469 | new ContentObserver(mWindowManagerService.mH) { |
| 470 | @Override |
| 471 | public void onChange(boolean selfChange) { |
| 472 | updateShowTouchesFromSettings(); |
| 473 | } |
| 474 | }); |
| 475 | } |
| 476 | |
| 477 | private int getShowTouchesSetting(int defaultValue) { |
| 478 | int result = defaultValue; |
| 479 | try { |
| 480 | result = Settings.System.getInt(mContext.getContentResolver(), |
| 481 | Settings.System.SHOW_TOUCHES); |
| 482 | } catch (SettingNotFoundException snfe) { |
| 483 | } |
| 484 | return result; |
| 485 | } |
| 486 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 487 | public void dump(PrintWriter pw) { |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 488 | String dumpStr = nativeDump(); |
| 489 | if (dumpStr != null) { |
| 490 | pw.println(dumpStr); |
| 491 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 492 | } |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 493 | |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 494 | // Called by the heartbeat to ensure locks are not held indefnitely (for deadlock detection). |
| 495 | public void monitor() { |
| 496 | synchronized (mInputFilterLock) { } |
| 497 | nativeMonitor(); |
| 498 | } |
| 499 | |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 500 | private final class InputFilterHost implements InputFilter.Host { |
| 501 | private boolean mDisconnected; |
| 502 | |
| 503 | public void disconnectLocked() { |
| 504 | mDisconnected = true; |
| 505 | } |
| 506 | |
| 507 | public void sendInputEvent(InputEvent event, int policyFlags) { |
| 508 | if (event == null) { |
| 509 | throw new IllegalArgumentException("event must not be null"); |
| 510 | } |
| 511 | |
| 512 | synchronized (mInputFilterLock) { |
| 513 | if (!mDisconnected) { |
| 514 | nativeInjectInputEvent(event, 0, 0, INPUT_EVENT_INJECTION_SYNC_NONE, 0, |
| 515 | policyFlags | WindowManagerPolicy.FLAG_FILTERED); |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 521 | /* |
| 522 | * Callbacks from native. |
| 523 | */ |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 524 | private final class Callbacks { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 525 | static final String TAG = "InputManager-Callbacks"; |
| 526 | |
| 527 | private static final boolean DEBUG_VIRTUAL_KEYS = false; |
| 528 | private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml"; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 529 | private static final String CALIBRATION_DIR_PATH = "usr/idc/"; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 530 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 531 | @SuppressWarnings("unused") |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 532 | public void notifyConfigurationChanged(long whenNanos) { |
Jeff Brown | b09abc1 | 2011-01-13 21:08:27 -0800 | [diff] [blame] | 533 | mWindowManagerService.mInputMonitor.notifyConfigurationChanged(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | @SuppressWarnings("unused") |
| 537 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 538 | mWindowManagerService.mInputMonitor.notifyLidSwitchChanged(whenNanos, lidOpen); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | @SuppressWarnings("unused") |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 542 | public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) { |
| 543 | mWindowManagerService.mInputMonitor.notifyInputChannelBroken(inputWindowHandle); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 544 | } |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 545 | |
| 546 | @SuppressWarnings("unused") |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 547 | public long notifyANR(InputApplicationHandle inputApplicationHandle, |
| 548 | InputWindowHandle inputWindowHandle) { |
| 549 | return mWindowManagerService.mInputMonitor.notifyANR( |
| 550 | inputApplicationHandle, inputWindowHandle); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 551 | } |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 552 | |
| 553 | @SuppressWarnings("unused") |
| 554 | final boolean filterInputEvent(InputEvent event, int policyFlags) { |
| 555 | synchronized (mInputFilterLock) { |
| 556 | if (mInputFilter != null) { |
| 557 | mInputFilter.filterInputEvent(event, policyFlags); |
| 558 | return false; |
| 559 | } |
| 560 | } |
| 561 | event.recycle(); |
| 562 | return true; |
| 563 | } |
| 564 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 565 | @SuppressWarnings("unused") |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 566 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 567 | return mWindowManagerService.mInputMonitor.interceptKeyBeforeQueueing( |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 568 | event, policyFlags, isScreenOn); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 569 | } |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 570 | |
| 571 | @SuppressWarnings("unused") |
| 572 | public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { |
| 573 | return mWindowManagerService.mInputMonitor.interceptMotionBeforeQueueingWhenScreenOff( |
| 574 | policyFlags); |
| 575 | } |
| 576 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 577 | @SuppressWarnings("unused") |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 578 | public boolean interceptKeyBeforeDispatching(InputWindowHandle focus, |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 579 | KeyEvent event, int policyFlags) { |
| 580 | return mWindowManagerService.mInputMonitor.interceptKeyBeforeDispatching( |
| 581 | focus, event, policyFlags); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | @SuppressWarnings("unused") |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 585 | public KeyEvent dispatchUnhandledKey(InputWindowHandle focus, |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 586 | KeyEvent event, int policyFlags) { |
| 587 | return mWindowManagerService.mInputMonitor.dispatchUnhandledKey( |
| 588 | focus, event, policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | @SuppressWarnings("unused") |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 592 | public boolean checkInjectEventsPermission(int injectorPid, int injectorUid) { |
| 593 | return mContext.checkPermission( |
| 594 | android.Manifest.permission.INJECT_EVENTS, injectorPid, injectorUid) |
| 595 | == PackageManager.PERMISSION_GRANTED; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 596 | } |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 597 | |
| 598 | @SuppressWarnings("unused") |
| 599 | public int getVirtualKeyQuietTimeMillis() { |
| 600 | return mContext.getResources().getInteger( |
| 601 | com.android.internal.R.integer.config_virtualKeyQuietTimeMillis); |
| 602 | } |
| 603 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 604 | @SuppressWarnings("unused") |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 605 | public String[] getExcludedDeviceNames() { |
| 606 | ArrayList<String> names = new ArrayList<String>(); |
| 607 | |
| 608 | // Read partner-provided list of excluded input devices |
| 609 | XmlPullParser parser = null; |
| 610 | // Environment.getRootDirectory() is a fancy way of saying ANDROID_ROOT or "/system". |
| 611 | File confFile = new File(Environment.getRootDirectory(), EXCLUDED_DEVICES_PATH); |
| 612 | FileReader confreader = null; |
| 613 | try { |
| 614 | confreader = new FileReader(confFile); |
| 615 | parser = Xml.newPullParser(); |
| 616 | parser.setInput(confreader); |
| 617 | XmlUtils.beginDocument(parser, "devices"); |
| 618 | |
| 619 | while (true) { |
| 620 | XmlUtils.nextElement(parser); |
| 621 | if (!"device".equals(parser.getName())) { |
| 622 | break; |
| 623 | } |
| 624 | String name = parser.getAttributeValue(null, "name"); |
| 625 | if (name != null) { |
| 626 | names.add(name); |
| 627 | } |
| 628 | } |
| 629 | } catch (FileNotFoundException e) { |
| 630 | // It's ok if the file does not exist. |
| 631 | } catch (Exception e) { |
| 632 | Slog.e(TAG, "Exception while parsing '" + confFile.getAbsolutePath() + "'", e); |
| 633 | } finally { |
| 634 | try { if (confreader != null) confreader.close(); } catch (IOException e) { } |
| 635 | } |
| 636 | |
| 637 | return names.toArray(new String[names.size()]); |
| 638 | } |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 639 | |
| 640 | @SuppressWarnings("unused") |
| 641 | public int getKeyRepeatTimeout() { |
| 642 | return ViewConfiguration.getKeyRepeatTimeout(); |
| 643 | } |
| 644 | |
| 645 | @SuppressWarnings("unused") |
| 646 | public int getKeyRepeatDelay() { |
| 647 | return ViewConfiguration.getKeyRepeatDelay(); |
| 648 | } |
| 649 | |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 650 | @SuppressWarnings("unused") |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 651 | public int getHoverTapTimeout() { |
| 652 | return ViewConfiguration.getHoverTapTimeout(); |
| 653 | } |
| 654 | |
| 655 | @SuppressWarnings("unused") |
| 656 | public int getHoverTapSlop() { |
| 657 | return ViewConfiguration.getHoverTapSlop(); |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | @SuppressWarnings("unused") |
| 661 | public int getDoubleTapTimeout() { |
| 662 | return ViewConfiguration.getDoubleTapTimeout(); |
| 663 | } |
| 664 | |
| 665 | @SuppressWarnings("unused") |
| 666 | public int getLongPressTimeout() { |
| 667 | return ViewConfiguration.getLongPressTimeout(); |
| 668 | } |
| 669 | |
| 670 | @SuppressWarnings("unused") |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 671 | public int getMaxEventsPerSecond() { |
| 672 | int result = 0; |
| 673 | try { |
| 674 | result = Integer.parseInt(SystemProperties.get("windowsmgr.max_events_per_sec")); |
| 675 | } catch (NumberFormatException e) { |
| 676 | } |
| 677 | if (result < 1) { |
makarand.karvekar | 88dd6e6 | 2011-03-02 17:11:14 -0600 | [diff] [blame] | 678 | result = 55; |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 679 | } |
| 680 | return result; |
| 681 | } |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 682 | |
| 683 | @SuppressWarnings("unused") |
| 684 | public int getPointerLayer() { |
| 685 | return mWindowManagerService.mPolicy.windowTypeToLayerLw( |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 686 | WindowManager.LayoutParams.TYPE_POINTER) |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 687 | * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 688 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 689 | } |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 690 | |
| 691 | @SuppressWarnings("unused") |
| 692 | public PointerIcon getPointerIcon() { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 693 | return PointerIcon.getDefaultIcon(mContext); |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 694 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 695 | } |
| 696 | } |