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