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 | |
| 17 | #define LOG_TAG "InputManager-JNI" |
| 18 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
| 20 | |
| 21 | // Log debug messages about InputReaderPolicy |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 22 | #define DEBUG_INPUT_READER_POLICY 0 |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 23 | |
| 24 | // Log debug messages about InputDispatcherPolicy |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 25 | #define DEBUG_INPUT_DISPATCHER_POLICY 0 |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 26 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 27 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 28 | #include "JNIHelp.h" |
| 29 | #include "jni.h" |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 30 | #include <limits.h> |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 31 | #include <android_runtime/AndroidRuntime.h> |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 32 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 33 | #include <utils/Log.h> |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 34 | #include <utils/Looper.h> |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 35 | #include <utils/threads.h> |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 36 | |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 37 | #include <input/InputManager.h> |
| 38 | #include <input/PointerController.h> |
| 39 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 40 | #include <android_os_MessageQueue.h> |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 41 | #include <android_view_KeyEvent.h> |
| 42 | #include <android_view_MotionEvent.h> |
| 43 | #include <android_view_InputChannel.h> |
| 44 | #include <android/graphics/GraphicsJNI.h> |
| 45 | |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 46 | #include "com_android_server_PowerManagerService.h" |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 47 | #include "com_android_server_InputApplication.h" |
| 48 | #include "com_android_server_InputApplicationHandle.h" |
| 49 | #include "com_android_server_InputWindow.h" |
| 50 | #include "com_android_server_InputWindowHandle.h" |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 51 | |
| 52 | namespace android { |
| 53 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 54 | static struct { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 55 | jmethodID notifyConfigurationChanged; |
| 56 | jmethodID notifyLidSwitchChanged; |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 57 | jmethodID notifyInputChannelBroken; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 58 | jmethodID notifyANR; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 59 | jmethodID interceptKeyBeforeQueueing; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 60 | jmethodID interceptMotionBeforeQueueingWhenScreenOff; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 61 | jmethodID interceptKeyBeforeDispatching; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 62 | jmethodID dispatchUnhandledKey; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 63 | jmethodID checkInjectEventsPermission; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 64 | jmethodID filterTouchEvents; |
| 65 | jmethodID filterJumpyTouchEvents; |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 66 | jmethodID getVirtualKeyQuietTimeMillis; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 67 | jmethodID getExcludedDeviceNames; |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 68 | jmethodID getKeyRepeatTimeout; |
| 69 | jmethodID getKeyRepeatDelay; |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 70 | jmethodID getMaxEventsPerSecond; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 71 | jmethodID getPointerLayer; |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 72 | jmethodID getPointerIcon; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 73 | } gCallbacksClassInfo; |
| 74 | |
| 75 | static struct { |
| 76 | jclass clazz; |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 77 | } gKeyEventClassInfo; |
| 78 | |
| 79 | static struct { |
| 80 | jclass clazz; |
| 81 | } gMotionEventClassInfo; |
| 82 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 83 | static struct { |
| 84 | jclass clazz; |
| 85 | |
| 86 | jmethodID ctor; |
| 87 | jmethodID addMotionRange; |
| 88 | |
| 89 | jfieldID mId; |
| 90 | jfieldID mName; |
| 91 | jfieldID mSources; |
| 92 | jfieldID mKeyboardType; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 93 | } gInputDeviceClassInfo; |
| 94 | |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 95 | static struct { |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 96 | jfieldID touchscreen; |
| 97 | jfieldID keyboard; |
| 98 | jfieldID navigation; |
| 99 | } gConfigurationClassInfo; |
| 100 | |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 101 | static struct { |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 102 | jfieldID bitmap; |
| 103 | jfieldID hotSpotX; |
| 104 | jfieldID hotSpotY; |
| 105 | } gPointerIconClassInfo; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 106 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 107 | |
| 108 | // --- Global functions --- |
| 109 | |
| 110 | static jobject getInputApplicationHandleObjLocalRef(JNIEnv* env, |
| 111 | const sp<InputApplicationHandle>& inputApplicationHandle) { |
| 112 | if (inputApplicationHandle == NULL) { |
| 113 | return NULL; |
| 114 | } |
| 115 | return static_cast<NativeInputApplicationHandle*>(inputApplicationHandle.get())-> |
| 116 | getInputApplicationHandleObjLocalRef(env); |
| 117 | } |
| 118 | |
| 119 | static jobject getInputWindowHandleObjLocalRef(JNIEnv* env, |
| 120 | const sp<InputWindowHandle>& inputWindowHandle) { |
| 121 | if (inputWindowHandle == NULL) { |
| 122 | return NULL; |
| 123 | } |
| 124 | return static_cast<NativeInputWindowHandle*>(inputWindowHandle.get())-> |
| 125 | getInputWindowHandleObjLocalRef(env); |
| 126 | } |
| 127 | |
| 128 | |
| 129 | // --- NativeInputManager --- |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 130 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 131 | class NativeInputManager : public virtual RefBase, |
| 132 | public virtual InputReaderPolicyInterface, |
| 133 | public virtual InputDispatcherPolicyInterface { |
| 134 | protected: |
| 135 | virtual ~NativeInputManager(); |
| 136 | |
| 137 | public: |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 138 | NativeInputManager(jobject callbacksObj, const sp<Looper>& looper); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 139 | |
| 140 | inline sp<InputManager> getInputManager() const { return mInputManager; } |
| 141 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 142 | void dump(String8& dump); |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 143 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 144 | void setDisplaySize(int32_t displayId, int32_t width, int32_t height); |
| 145 | void setDisplayOrientation(int32_t displayId, int32_t orientation); |
| 146 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 147 | status_t registerInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 148 | const sp<InputWindowHandle>& inputWindowHandle, bool monitor); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 149 | status_t unregisterInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel); |
| 150 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 151 | void setInputWindows(JNIEnv* env, jobjectArray windowObjArray); |
| 152 | void setFocusedApplication(JNIEnv* env, jobject applicationObj); |
| 153 | void setInputDispatchMode(bool enabled, bool frozen); |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 154 | void setSystemUiVisibility(int32_t visibility); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 155 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 156 | /* --- InputReaderPolicyInterface implementation --- */ |
| 157 | |
| 158 | virtual bool getDisplayInfo(int32_t displayId, |
| 159 | int32_t* width, int32_t* height, int32_t* orientation); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 160 | virtual bool filterTouchEvents(); |
| 161 | virtual bool filterJumpyTouchEvents(); |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 162 | virtual nsecs_t getVirtualKeyQuietTime(); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 163 | virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames); |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 164 | virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 165 | |
| 166 | /* --- InputDispatcherPolicyInterface implementation --- */ |
| 167 | |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 168 | virtual void notifySwitch(nsecs_t when, int32_t switchCode, int32_t switchValue, |
| 169 | uint32_t policyFlags); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 170 | virtual void notifyConfigurationChanged(nsecs_t when); |
Jeff Brown | 519e024 | 2010-09-15 15:18:56 -0700 | [diff] [blame] | 171 | virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 172 | const sp<InputWindowHandle>& inputWindowHandle); |
| 173 | virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 174 | virtual nsecs_t getKeyRepeatTimeout(); |
Jeff Brown | b21fb10 | 2010-09-07 10:44:57 -0700 | [diff] [blame] | 175 | virtual nsecs_t getKeyRepeatDelay(); |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 176 | virtual int32_t getMaxEventsPerSecond(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 177 | virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 178 | virtual void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags); |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 179 | virtual bool interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle, |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 180 | const KeyEvent* keyEvent, uint32_t policyFlags); |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 181 | virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 182 | const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent); |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 183 | virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType); |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 184 | virtual bool checkInjectEventsPermissionNonReentrant( |
| 185 | int32_t injectorPid, int32_t injectorUid); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 186 | |
| 187 | private: |
| 188 | sp<InputManager> mInputManager; |
| 189 | |
| 190 | jobject mCallbacksObj; |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 191 | sp<Looper> mLooper; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 192 | |
| 193 | // Cached filtering policies. |
| 194 | int32_t mFilterTouchEvents; |
| 195 | int32_t mFilterJumpyTouchEvents; |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 196 | nsecs_t mVirtualKeyQuietTime; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 197 | |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 198 | // Cached key repeat policy. |
| 199 | nsecs_t mKeyRepeatTimeout; |
| 200 | nsecs_t mKeyRepeatDelay; |
| 201 | |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 202 | // Cached throttling policy. |
| 203 | int32_t mMaxEventsPerSecond; |
| 204 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 205 | Mutex mLock; |
| 206 | struct Locked { |
| 207 | // Display size information. |
| 208 | int32_t displayWidth, displayHeight; // -1 when initialized |
| 209 | int32_t displayOrientation; |
| 210 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 211 | // System UI visibility. |
| 212 | int32_t systemUiVisibility; |
| 213 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 214 | // Pointer controller singleton, created and destroyed as needed. |
| 215 | wp<PointerController> pointerController; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 216 | } mLocked; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 217 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 218 | void updateInactivityFadeDelayLocked(const sp<PointerController>& controller); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 219 | void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags); |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 220 | |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 221 | // Power manager interactions. |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 222 | bool isScreenOn(); |
| 223 | bool isScreenBright(); |
| 224 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 225 | static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 226 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 227 | static inline JNIEnv* jniEnv() { |
| 228 | return AndroidRuntime::getJNIEnv(); |
| 229 | } |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 230 | }; |
| 231 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 232 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 233 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 234 | NativeInputManager::NativeInputManager(jobject callbacksObj, const sp<Looper>& looper) : |
| 235 | mLooper(looper), |
| 236 | mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1), mVirtualKeyQuietTime(-1), |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 237 | mKeyRepeatTimeout(-1), mKeyRepeatDelay(-1), |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 238 | mMaxEventsPerSecond(-1) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 239 | JNIEnv* env = jniEnv(); |
| 240 | |
| 241 | mCallbacksObj = env->NewGlobalRef(callbacksObj); |
| 242 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 243 | { |
| 244 | AutoMutex _l(mLock); |
| 245 | mLocked.displayWidth = -1; |
| 246 | mLocked.displayHeight = -1; |
| 247 | mLocked.displayOrientation = ROTATION_0; |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 248 | |
| 249 | mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 250 | } |
| 251 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 252 | sp<EventHub> eventHub = new EventHub(); |
| 253 | mInputManager = new InputManager(eventHub, this, this); |
| 254 | } |
| 255 | |
| 256 | NativeInputManager::~NativeInputManager() { |
| 257 | JNIEnv* env = jniEnv(); |
| 258 | |
| 259 | env->DeleteGlobalRef(mCallbacksObj); |
| 260 | } |
| 261 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 262 | void NativeInputManager::dump(String8& dump) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 263 | mInputManager->getReader()->dump(dump); |
| 264 | dump.append("\n"); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 265 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 266 | mInputManager->getDispatcher()->dump(dump); |
| 267 | dump.append("\n"); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 270 | bool NativeInputManager::checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 271 | if (env->ExceptionCheck()) { |
| 272 | LOGE("An exception was thrown by callback '%s'.", methodName); |
| 273 | LOGE_EX(env); |
| 274 | env->ExceptionClear(); |
| 275 | return true; |
| 276 | } |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | void NativeInputManager::setDisplaySize(int32_t displayId, int32_t width, int32_t height) { |
| 281 | if (displayId == 0) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 282 | AutoMutex _l(mLock); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 283 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 284 | if (mLocked.displayWidth != width || mLocked.displayHeight != height) { |
| 285 | mLocked.displayWidth = width; |
| 286 | mLocked.displayHeight = height; |
| 287 | |
| 288 | sp<PointerController> controller = mLocked.pointerController.promote(); |
| 289 | if (controller != NULL) { |
| 290 | controller->setDisplaySize(width, height); |
| 291 | } |
| 292 | } |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | |
| 296 | void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation) { |
| 297 | if (displayId == 0) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 298 | AutoMutex _l(mLock); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 299 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 300 | if (mLocked.displayOrientation != orientation) { |
| 301 | mLocked.displayOrientation = orientation; |
| 302 | |
| 303 | sp<PointerController> controller = mLocked.pointerController.promote(); |
| 304 | if (controller != NULL) { |
| 305 | controller->setDisplayOrientation(orientation); |
| 306 | } |
| 307 | } |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 311 | status_t NativeInputManager::registerInputChannel(JNIEnv* env, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 312 | const sp<InputChannel>& inputChannel, |
| 313 | const sp<InputWindowHandle>& inputWindowHandle, bool monitor) { |
| 314 | return mInputManager->getDispatcher()->registerInputChannel( |
| 315 | inputChannel, inputWindowHandle, monitor); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | status_t NativeInputManager::unregisterInputChannel(JNIEnv* env, |
| 319 | const sp<InputChannel>& inputChannel) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 320 | return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 323 | bool NativeInputManager::getDisplayInfo(int32_t displayId, |
| 324 | int32_t* width, int32_t* height, int32_t* orientation) { |
| 325 | bool result = false; |
| 326 | if (displayId == 0) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 327 | AutoMutex _l(mLock); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 328 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 329 | if (mLocked.displayWidth > 0 && mLocked.displayHeight > 0) { |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 330 | if (width) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 331 | *width = mLocked.displayWidth; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 332 | } |
| 333 | if (height) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 334 | *height = mLocked.displayHeight; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 335 | } |
| 336 | if (orientation) { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 337 | *orientation = mLocked.displayOrientation; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 338 | } |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 339 | result = true; |
| 340 | } |
| 341 | } |
| 342 | return result; |
| 343 | } |
| 344 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 345 | bool NativeInputManager::filterTouchEvents() { |
| 346 | if (mFilterTouchEvents < 0) { |
| 347 | JNIEnv* env = jniEnv(); |
| 348 | |
| 349 | jboolean result = env->CallBooleanMethod(mCallbacksObj, |
| 350 | gCallbacksClassInfo.filterTouchEvents); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 351 | if (checkAndClearExceptionFromCallback(env, "filterTouchEvents")) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 352 | result = false; |
| 353 | } |
| 354 | |
| 355 | mFilterTouchEvents = result ? 1 : 0; |
| 356 | } |
| 357 | return mFilterTouchEvents; |
| 358 | } |
| 359 | |
| 360 | bool NativeInputManager::filterJumpyTouchEvents() { |
| 361 | if (mFilterJumpyTouchEvents < 0) { |
| 362 | JNIEnv* env = jniEnv(); |
| 363 | |
| 364 | jboolean result = env->CallBooleanMethod(mCallbacksObj, |
| 365 | gCallbacksClassInfo.filterJumpyTouchEvents); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 366 | if (checkAndClearExceptionFromCallback(env, "filterJumpyTouchEvents")) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 367 | result = false; |
| 368 | } |
| 369 | |
| 370 | mFilterJumpyTouchEvents = result ? 1 : 0; |
| 371 | } |
| 372 | return mFilterJumpyTouchEvents; |
| 373 | } |
| 374 | |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 375 | nsecs_t NativeInputManager::getVirtualKeyQuietTime() { |
| 376 | if (mVirtualKeyQuietTime < 0) { |
| 377 | JNIEnv* env = jniEnv(); |
| 378 | |
| 379 | jint result = env->CallIntMethod(mCallbacksObj, |
| 380 | gCallbacksClassInfo.getVirtualKeyQuietTimeMillis); |
| 381 | if (checkAndClearExceptionFromCallback(env, "getVirtualKeyQuietTimeMillis")) { |
| 382 | result = 0; |
| 383 | } |
| 384 | if (result < 0) { |
| 385 | result = 0; |
| 386 | } |
| 387 | |
| 388 | mVirtualKeyQuietTime = milliseconds_to_nanoseconds(result); |
| 389 | } |
| 390 | return mVirtualKeyQuietTime; |
| 391 | } |
| 392 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 393 | void NativeInputManager::getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames) { |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 394 | outExcludedDeviceNames.clear(); |
| 395 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 396 | JNIEnv* env = jniEnv(); |
| 397 | |
| 398 | jobjectArray result = jobjectArray(env->CallObjectMethod(mCallbacksObj, |
| 399 | gCallbacksClassInfo.getExcludedDeviceNames)); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 400 | if (! checkAndClearExceptionFromCallback(env, "getExcludedDeviceNames") && result) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 401 | jsize length = env->GetArrayLength(result); |
| 402 | for (jsize i = 0; i < length; i++) { |
| 403 | jstring item = jstring(env->GetObjectArrayElement(result, i)); |
| 404 | |
| 405 | const char* deviceNameChars = env->GetStringUTFChars(item, NULL); |
| 406 | outExcludedDeviceNames.add(String8(deviceNameChars)); |
| 407 | env->ReleaseStringUTFChars(item, deviceNameChars); |
| 408 | |
| 409 | env->DeleteLocalRef(item); |
| 410 | } |
| 411 | env->DeleteLocalRef(result); |
| 412 | } |
| 413 | } |
| 414 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 415 | sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t deviceId) { |
| 416 | AutoMutex _l(mLock); |
| 417 | |
| 418 | sp<PointerController> controller = mLocked.pointerController.promote(); |
| 419 | if (controller == NULL) { |
| 420 | JNIEnv* env = jniEnv(); |
| 421 | jint layer = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getPointerLayer); |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 422 | if (checkAndClearExceptionFromCallback(env, "getPointerLayer")) { |
| 423 | layer = -1; |
| 424 | } |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 425 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 426 | controller = new PointerController(mLooper, layer); |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 427 | mLocked.pointerController = controller; |
| 428 | |
| 429 | controller->setDisplaySize(mLocked.displayWidth, mLocked.displayHeight); |
| 430 | controller->setDisplayOrientation(mLocked.displayOrientation); |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 431 | |
| 432 | jobject iconObj = env->CallObjectMethod(mCallbacksObj, gCallbacksClassInfo.getPointerIcon); |
| 433 | if (!checkAndClearExceptionFromCallback(env, "getPointerIcon") && iconObj) { |
| 434 | jfloat iconHotSpotX = env->GetFloatField(iconObj, gPointerIconClassInfo.hotSpotX); |
| 435 | jfloat iconHotSpotY = env->GetFloatField(iconObj, gPointerIconClassInfo.hotSpotY); |
| 436 | jobject iconBitmapObj = env->GetObjectField(iconObj, gPointerIconClassInfo.bitmap); |
| 437 | if (iconBitmapObj) { |
| 438 | SkBitmap* iconBitmap = GraphicsJNI::getNativeBitmap(env, iconBitmapObj); |
| 439 | if (iconBitmap) { |
| 440 | controller->setPointerIcon(iconBitmap, iconHotSpotX, iconHotSpotY); |
| 441 | } |
| 442 | env->DeleteLocalRef(iconBitmapObj); |
| 443 | } |
| 444 | env->DeleteLocalRef(iconObj); |
| 445 | } |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 446 | |
| 447 | updateInactivityFadeDelayLocked(controller); |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 448 | } |
| 449 | return controller; |
| 450 | } |
| 451 | |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 452 | void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode, |
| 453 | int32_t switchValue, uint32_t policyFlags) { |
| 454 | #if DEBUG_INPUT_DISPATCHER_POLICY |
| 455 | LOGD("notifySwitch - when=%lld, switchCode=%d, switchValue=%d, policyFlags=0x%x", |
| 456 | when, switchCode, switchValue, policyFlags); |
| 457 | #endif |
| 458 | |
| 459 | JNIEnv* env = jniEnv(); |
| 460 | |
| 461 | switch (switchCode) { |
| 462 | case SW_LID: |
| 463 | env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyLidSwitchChanged, |
| 464 | when, switchValue == 0); |
| 465 | checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged"); |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 470 | void NativeInputManager::notifyConfigurationChanged(nsecs_t when) { |
| 471 | #if DEBUG_INPUT_DISPATCHER_POLICY |
| 472 | LOGD("notifyConfigurationChanged - when=%lld", when); |
| 473 | #endif |
| 474 | |
| 475 | JNIEnv* env = jniEnv(); |
| 476 | |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 477 | env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged, when); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 478 | checkAndClearExceptionFromCallback(env, "notifyConfigurationChanged"); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Jeff Brown | 519e024 | 2010-09-15 15:18:56 -0700 | [diff] [blame] | 481 | nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 482 | const sp<InputWindowHandle>& inputWindowHandle) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 483 | #if DEBUG_INPUT_DISPATCHER_POLICY |
| 484 | LOGD("notifyANR"); |
| 485 | #endif |
| 486 | |
| 487 | JNIEnv* env = jniEnv(); |
| 488 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 489 | jobject inputApplicationHandleObj = |
| 490 | getInputApplicationHandleObjLocalRef(env, inputApplicationHandle); |
| 491 | jobject inputWindowHandleObj = |
| 492 | getInputWindowHandleObjLocalRef(env, inputWindowHandle); |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 493 | |
Jeff Brown | 519e024 | 2010-09-15 15:18:56 -0700 | [diff] [blame] | 494 | jlong newTimeout = env->CallLongMethod(mCallbacksObj, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 495 | gCallbacksClassInfo.notifyANR, inputApplicationHandleObj, inputWindowHandleObj); |
Jeff Brown | 519e024 | 2010-09-15 15:18:56 -0700 | [diff] [blame] | 496 | if (checkAndClearExceptionFromCallback(env, "notifyANR")) { |
| 497 | newTimeout = 0; // abort dispatch |
| 498 | } else { |
| 499 | assert(newTimeout >= 0); |
| 500 | } |
| 501 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 502 | env->DeleteLocalRef(inputWindowHandleObj); |
| 503 | env->DeleteLocalRef(inputApplicationHandleObj); |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 504 | return newTimeout; |
| 505 | } |
| 506 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 507 | void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 508 | #if DEBUG_INPUT_DISPATCHER_POLICY |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 509 | LOGD("notifyInputChannelBroken"); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 510 | #endif |
| 511 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 512 | JNIEnv* env = jniEnv(); |
| 513 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 514 | jobject inputWindowHandleObj = |
| 515 | getInputWindowHandleObjLocalRef(env, inputWindowHandle); |
| 516 | if (inputWindowHandleObj) { |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 517 | env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyInputChannelBroken, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 518 | inputWindowHandleObj); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 519 | checkAndClearExceptionFromCallback(env, "notifyInputChannelBroken"); |
| 520 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 521 | env->DeleteLocalRef(inputWindowHandleObj); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 522 | } |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 525 | nsecs_t NativeInputManager::getKeyRepeatTimeout() { |
| 526 | if (! isScreenOn()) { |
| 527 | // Disable key repeat when the screen is off. |
| 528 | return -1; |
| 529 | } else { |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 530 | if (mKeyRepeatTimeout < 0) { |
| 531 | JNIEnv* env = jniEnv(); |
| 532 | |
| 533 | jint result = env->CallIntMethod(mCallbacksObj, |
| 534 | gCallbacksClassInfo.getKeyRepeatTimeout); |
| 535 | if (checkAndClearExceptionFromCallback(env, "getKeyRepeatTimeout")) { |
| 536 | result = 500; |
| 537 | } |
| 538 | |
| 539 | mKeyRepeatTimeout = milliseconds_to_nanoseconds(result); |
| 540 | } |
| 541 | return mKeyRepeatTimeout; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 542 | } |
| 543 | } |
| 544 | |
Jeff Brown | b21fb10 | 2010-09-07 10:44:57 -0700 | [diff] [blame] | 545 | nsecs_t NativeInputManager::getKeyRepeatDelay() { |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 546 | if (mKeyRepeatDelay < 0) { |
| 547 | JNIEnv* env = jniEnv(); |
| 548 | |
| 549 | jint result = env->CallIntMethod(mCallbacksObj, |
| 550 | gCallbacksClassInfo.getKeyRepeatDelay); |
| 551 | if (checkAndClearExceptionFromCallback(env, "getKeyRepeatDelay")) { |
| 552 | result = 50; |
| 553 | } |
| 554 | |
| 555 | mKeyRepeatDelay = milliseconds_to_nanoseconds(result); |
| 556 | } |
| 557 | return mKeyRepeatDelay; |
Jeff Brown | b21fb10 | 2010-09-07 10:44:57 -0700 | [diff] [blame] | 558 | } |
| 559 | |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 560 | int32_t NativeInputManager::getMaxEventsPerSecond() { |
| 561 | if (mMaxEventsPerSecond < 0) { |
| 562 | JNIEnv* env = jniEnv(); |
| 563 | |
| 564 | jint result = env->CallIntMethod(mCallbacksObj, |
| 565 | gCallbacksClassInfo.getMaxEventsPerSecond); |
| 566 | if (checkAndClearExceptionFromCallback(env, "getMaxEventsPerSecond")) { |
Jeff Brown | 3d8c9bd | 2010-08-18 17:48:53 -0700 | [diff] [blame] | 567 | result = 60; |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | mMaxEventsPerSecond = result; |
| 571 | } |
| 572 | return mMaxEventsPerSecond; |
| 573 | } |
| 574 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 575 | void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArray) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 576 | Vector<InputWindow> windows; |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 577 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 578 | jsize length = env->GetArrayLength(windowObjArray); |
| 579 | for (jsize i = 0; i < length; i++) { |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 580 | jobject windowObj = env->GetObjectArrayElement(windowObjArray, i); |
| 581 | if (! windowObj) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 582 | break; // found null element indicating end of used portion of the array |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 583 | } |
| 584 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 585 | windows.push(); |
| 586 | InputWindow& window = windows.editTop(); |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 587 | android_server_InputWindow_toNative(env, windowObj, &window); |
| 588 | if (window.inputChannel == NULL) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 589 | windows.pop(); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 590 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 591 | env->DeleteLocalRef(windowObj); |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 592 | } |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 593 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 594 | mInputManager->getDispatcher()->setInputWindows(windows); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 597 | void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationObj) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 598 | if (applicationObj) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 599 | InputApplication application; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 600 | android_server_InputApplication_toNative(env, applicationObj, &application); |
| 601 | if (application.inputApplicationHandle != NULL) { |
| 602 | mInputManager->getDispatcher()->setFocusedApplication(&application); |
Jeff Brown | a2cc28d | 2011-03-25 11:58:46 -0700 | [diff] [blame] | 603 | return; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 604 | } |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 605 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 606 | mInputManager->getDispatcher()->setFocusedApplication(NULL); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 610 | mInputManager->getDispatcher()->setInputDispatchMode(enabled, frozen); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 613 | void NativeInputManager::setSystemUiVisibility(int32_t visibility) { |
| 614 | AutoMutex _l(mLock); |
| 615 | |
| 616 | if (mLocked.systemUiVisibility != visibility) { |
| 617 | mLocked.systemUiVisibility = visibility; |
| 618 | |
| 619 | sp<PointerController> controller = mLocked.pointerController.promote(); |
| 620 | if (controller != NULL) { |
| 621 | updateInactivityFadeDelayLocked(controller); |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | void NativeInputManager::updateInactivityFadeDelayLocked(const sp<PointerController>& controller) { |
| 627 | bool lightsOut = mLocked.systemUiVisibility & ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN; |
| 628 | controller->setInactivityFadeDelay(lightsOut |
| 629 | ? PointerController::INACTIVITY_FADE_DELAY_SHORT |
| 630 | : PointerController::INACTIVITY_FADE_DELAY_NORMAL); |
| 631 | } |
| 632 | |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 633 | bool NativeInputManager::isScreenOn() { |
| 634 | return android_server_PowerManagerService_isScreenOn(); |
| 635 | } |
| 636 | |
| 637 | bool NativeInputManager::isScreenBright() { |
| 638 | return android_server_PowerManagerService_isScreenBright(); |
| 639 | } |
| 640 | |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 641 | void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent, |
| 642 | uint32_t& policyFlags) { |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 643 | // Policy: |
| 644 | // - Ignore untrusted events and pass them along. |
| 645 | // - Ask the window manager what to do with normal events and trusted injected events. |
| 646 | // - For normal events wake and brighten the screen if currently off or dim. |
| 647 | if ((policyFlags & POLICY_FLAG_TRUSTED)) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 648 | nsecs_t when = keyEvent->getEventTime(); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 649 | bool isScreenOn = this->isScreenOn(); |
| 650 | bool isScreenBright = this->isScreenBright(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 651 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 652 | JNIEnv* env = jniEnv(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 653 | jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent); |
| 654 | jint wmActions; |
| 655 | if (keyEventObj) { |
| 656 | wmActions = env->CallIntMethod(mCallbacksObj, |
| 657 | gCallbacksClassInfo.interceptKeyBeforeQueueing, |
| 658 | keyEventObj, policyFlags, isScreenOn); |
| 659 | if (checkAndClearExceptionFromCallback(env, "interceptKeyBeforeQueueing")) { |
| 660 | wmActions = 0; |
| 661 | } |
| 662 | android_view_KeyEvent_recycle(env, keyEventObj); |
| 663 | env->DeleteLocalRef(keyEventObj); |
| 664 | } else { |
| 665 | LOGE("Failed to obtain key event object for interceptKeyBeforeQueueing."); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 666 | wmActions = 0; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 667 | } |
| 668 | |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 669 | if (!(policyFlags & POLICY_FLAG_INJECTED)) { |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 670 | if (!isScreenOn) { |
| 671 | policyFlags |= POLICY_FLAG_WOKE_HERE; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | if (!isScreenBright) { |
| 675 | policyFlags |= POLICY_FLAG_BRIGHT_HERE; |
| 676 | } |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 677 | } |
| 678 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 679 | handleInterceptActions(wmActions, when, /*byref*/ policyFlags); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 680 | } else { |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 681 | policyFlags |= POLICY_FLAG_PASS_TO_USER; |
| 682 | } |
| 683 | } |
| 684 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 685 | void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) { |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 686 | // Policy: |
| 687 | // - Ignore untrusted events and pass them along. |
| 688 | // - No special filtering for injected events required at this time. |
| 689 | // - Filter normal events based on screen state. |
| 690 | // - For normal events brighten (but do not wake) the screen if currently dim. |
| 691 | if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)) { |
| 692 | if (isScreenOn()) { |
| 693 | policyFlags |= POLICY_FLAG_PASS_TO_USER; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 694 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 695 | if (!isScreenBright()) { |
| 696 | policyFlags |= POLICY_FLAG_BRIGHT_HERE; |
| 697 | } |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 698 | } else { |
| 699 | JNIEnv* env = jniEnv(); |
| 700 | jint wmActions = env->CallIntMethod(mCallbacksObj, |
| 701 | gCallbacksClassInfo.interceptMotionBeforeQueueingWhenScreenOff, |
| 702 | policyFlags); |
| 703 | if (checkAndClearExceptionFromCallback(env, |
| 704 | "interceptMotionBeforeQueueingWhenScreenOff")) { |
| 705 | wmActions = 0; |
| 706 | } |
| 707 | |
| 708 | policyFlags |= POLICY_FLAG_WOKE_HERE | POLICY_FLAG_BRIGHT_HERE; |
| 709 | handleInterceptActions(wmActions, when, /*byref*/ policyFlags); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 710 | } |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 711 | } else { |
| 712 | policyFlags |= POLICY_FLAG_PASS_TO_USER; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 713 | } |
| 714 | } |
| 715 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 716 | void NativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when, |
| 717 | uint32_t& policyFlags) { |
| 718 | enum { |
| 719 | WM_ACTION_PASS_TO_USER = 1, |
| 720 | WM_ACTION_POKE_USER_ACTIVITY = 2, |
| 721 | WM_ACTION_GO_TO_SLEEP = 4, |
| 722 | }; |
| 723 | |
| 724 | if (wmActions & WM_ACTION_GO_TO_SLEEP) { |
Jeff Brown | 9267beb | 2011-03-07 20:11:22 -0800 | [diff] [blame] | 725 | #if DEBUG_INPUT_DISPATCHER_POLICY |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 726 | LOGD("handleInterceptActions: Going to sleep."); |
| 727 | #endif |
| 728 | android_server_PowerManagerService_goToSleep(when); |
| 729 | } |
| 730 | |
| 731 | if (wmActions & WM_ACTION_POKE_USER_ACTIVITY) { |
Jeff Brown | 9267beb | 2011-03-07 20:11:22 -0800 | [diff] [blame] | 732 | #if DEBUG_INPUT_DISPATCHER_POLICY |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 733 | LOGD("handleInterceptActions: Poking user activity."); |
| 734 | #endif |
| 735 | android_server_PowerManagerService_userActivity(when, POWER_MANAGER_BUTTON_EVENT); |
| 736 | } |
| 737 | |
| 738 | if (wmActions & WM_ACTION_PASS_TO_USER) { |
| 739 | policyFlags |= POLICY_FLAG_PASS_TO_USER; |
| 740 | } else { |
Jeff Brown | 9267beb | 2011-03-07 20:11:22 -0800 | [diff] [blame] | 741 | #if DEBUG_INPUT_DISPATCHER_POLICY |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 742 | LOGD("handleInterceptActions: Not passing key to user."); |
| 743 | #endif |
| 744 | } |
| 745 | } |
| 746 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 747 | bool NativeInputManager::interceptKeyBeforeDispatching( |
| 748 | const sp<InputWindowHandle>& inputWindowHandle, |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 749 | const KeyEvent* keyEvent, uint32_t policyFlags) { |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 750 | // Policy: |
| 751 | // - Ignore untrusted events and pass them along. |
| 752 | // - Filter normal events and trusted injected events through the window manager policy to |
| 753 | // handle the HOME key and the like. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 754 | bool result = false; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 755 | if (policyFlags & POLICY_FLAG_TRUSTED) { |
| 756 | JNIEnv* env = jniEnv(); |
Jeff Brown | d009787 | 2010-06-30 14:41:59 -0700 | [diff] [blame] | 757 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 758 | // Note: inputWindowHandle may be null. |
| 759 | jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 760 | jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent); |
| 761 | if (keyEventObj) { |
| 762 | jboolean consumed = env->CallBooleanMethod(mCallbacksObj, |
| 763 | gCallbacksClassInfo.interceptKeyBeforeDispatching, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 764 | inputWindowHandleObj, keyEventObj, policyFlags); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 765 | bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching"); |
| 766 | android_view_KeyEvent_recycle(env, keyEventObj); |
| 767 | env->DeleteLocalRef(keyEventObj); |
| 768 | result = consumed && !error; |
| 769 | } else { |
| 770 | LOGE("Failed to obtain key event object for interceptKeyBeforeDispatching."); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 771 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 772 | env->DeleteLocalRef(inputWindowHandleObj); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 773 | } |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 774 | return result; |
Jeff Brown | d009787 | 2010-06-30 14:41:59 -0700 | [diff] [blame] | 775 | } |
| 776 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 777 | bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 778 | const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) { |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 779 | // Policy: |
| 780 | // - Ignore untrusted events and do not perform default handling. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 781 | bool result = false; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 782 | if (policyFlags & POLICY_FLAG_TRUSTED) { |
| 783 | JNIEnv* env = jniEnv(); |
| 784 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 785 | // Note: inputWindowHandle may be null. |
| 786 | jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 787 | jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent); |
| 788 | if (keyEventObj) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 789 | jobject fallbackKeyEventObj = env->CallObjectMethod(mCallbacksObj, |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 790 | gCallbacksClassInfo.dispatchUnhandledKey, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 791 | inputWindowHandleObj, keyEventObj, policyFlags); |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame^] | 792 | if (checkAndClearExceptionFromCallback(env, "dispatchUnhandledKey")) { |
| 793 | fallbackKeyEventObj = NULL; |
| 794 | } |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 795 | android_view_KeyEvent_recycle(env, keyEventObj); |
| 796 | env->DeleteLocalRef(keyEventObj); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 797 | |
| 798 | if (fallbackKeyEventObj) { |
| 799 | // Note: outFallbackKeyEvent may be the same object as keyEvent. |
| 800 | if (!android_view_KeyEvent_toNative(env, fallbackKeyEventObj, |
| 801 | outFallbackKeyEvent)) { |
| 802 | result = true; |
| 803 | } |
| 804 | android_view_KeyEvent_recycle(env, fallbackKeyEventObj); |
| 805 | env->DeleteLocalRef(fallbackKeyEventObj); |
| 806 | } |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 807 | } else { |
| 808 | LOGE("Failed to obtain key event object for dispatchUnhandledKey."); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 809 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 810 | env->DeleteLocalRef(inputWindowHandleObj); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 811 | } |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 812 | return result; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 813 | } |
| 814 | |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 815 | void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType) { |
| 816 | android_server_PowerManagerService_userActivity(eventTime, eventType); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 819 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 820 | bool NativeInputManager::checkInjectEventsPermissionNonReentrant( |
| 821 | int32_t injectorPid, int32_t injectorUid) { |
| 822 | JNIEnv* env = jniEnv(); |
| 823 | jboolean result = env->CallBooleanMethod(mCallbacksObj, |
| 824 | gCallbacksClassInfo.checkInjectEventsPermission, injectorPid, injectorUid); |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame^] | 825 | if (checkAndClearExceptionFromCallback(env, "checkInjectEventsPermission")) { |
| 826 | result = false; |
| 827 | } |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 828 | return result; |
| 829 | } |
| 830 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 831 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 832 | // ---------------------------------------------------------------------------- |
| 833 | |
| 834 | static sp<NativeInputManager> gNativeInputManager; |
| 835 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 836 | static bool checkInputManagerUnitialized(JNIEnv* env) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 837 | if (gNativeInputManager == NULL) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 838 | LOGE("Input manager not initialized."); |
| 839 | jniThrowRuntimeException(env, "Input manager not initialized."); |
| 840 | return true; |
| 841 | } |
| 842 | return false; |
| 843 | } |
| 844 | |
| 845 | static void android_server_InputManager_nativeInit(JNIEnv* env, jclass clazz, |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 846 | jobject callbacks, jobject messageQueueObj) { |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 847 | if (gNativeInputManager == NULL) { |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 848 | sp<Looper> looper = android_os_MessageQueue_getLooper(env, messageQueueObj); |
| 849 | gNativeInputManager = new NativeInputManager(callbacks, looper); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 850 | } else { |
| 851 | LOGE("Input manager already initialized."); |
| 852 | jniThrowRuntimeException(env, "Input manager already initialized."); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 853 | } |
| 854 | } |
| 855 | |
| 856 | static void android_server_InputManager_nativeStart(JNIEnv* env, jclass clazz) { |
| 857 | if (checkInputManagerUnitialized(env)) { |
| 858 | return; |
| 859 | } |
| 860 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 861 | status_t result = gNativeInputManager->getInputManager()->start(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 862 | if (result) { |
| 863 | jniThrowRuntimeException(env, "Input manager could not be started."); |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | static void android_server_InputManager_nativeSetDisplaySize(JNIEnv* env, jclass clazz, |
| 868 | jint displayId, jint width, jint height) { |
| 869 | if (checkInputManagerUnitialized(env)) { |
| 870 | return; |
| 871 | } |
| 872 | |
| 873 | // XXX we could get this from the SurfaceFlinger directly instead of requiring it |
| 874 | // to be passed in like this, not sure which is better but leaving it like this |
| 875 | // keeps the window manager in direct control of when display transitions propagate down |
| 876 | // to the input dispatcher |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 877 | gNativeInputManager->setDisplaySize(displayId, width, height); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | static void android_server_InputManager_nativeSetDisplayOrientation(JNIEnv* env, jclass clazz, |
| 881 | jint displayId, jint orientation) { |
| 882 | if (checkInputManagerUnitialized(env)) { |
| 883 | return; |
| 884 | } |
| 885 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 886 | gNativeInputManager->setDisplayOrientation(displayId, orientation); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | static jint android_server_InputManager_nativeGetScanCodeState(JNIEnv* env, jclass clazz, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 890 | jint deviceId, jint sourceMask, jint scanCode) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 891 | if (checkInputManagerUnitialized(env)) { |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 892 | return AKEY_STATE_UNKNOWN; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 893 | } |
| 894 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 895 | return gNativeInputManager->getInputManager()->getReader()->getScanCodeState( |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 896 | deviceId, uint32_t(sourceMask), scanCode); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | static jint android_server_InputManager_nativeGetKeyCodeState(JNIEnv* env, jclass clazz, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 900 | jint deviceId, jint sourceMask, jint keyCode) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 901 | if (checkInputManagerUnitialized(env)) { |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 902 | return AKEY_STATE_UNKNOWN; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 903 | } |
| 904 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 905 | return gNativeInputManager->getInputManager()->getReader()->getKeyCodeState( |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 906 | deviceId, uint32_t(sourceMask), keyCode); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | static jint android_server_InputManager_nativeGetSwitchState(JNIEnv* env, jclass clazz, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 910 | jint deviceId, jint sourceMask, jint sw) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 911 | if (checkInputManagerUnitialized(env)) { |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 912 | return AKEY_STATE_UNKNOWN; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 913 | } |
| 914 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 915 | return gNativeInputManager->getInputManager()->getReader()->getSwitchState( |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 916 | deviceId, uint32_t(sourceMask), sw); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | static jboolean android_server_InputManager_nativeHasKeys(JNIEnv* env, jclass clazz, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 920 | jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 921 | if (checkInputManagerUnitialized(env)) { |
| 922 | return JNI_FALSE; |
| 923 | } |
| 924 | |
| 925 | int32_t* codes = env->GetIntArrayElements(keyCodes, NULL); |
| 926 | uint8_t* flags = env->GetBooleanArrayElements(outFlags, NULL); |
| 927 | jsize numCodes = env->GetArrayLength(keyCodes); |
| 928 | jboolean result; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 929 | if (numCodes == env->GetArrayLength(keyCodes)) { |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 930 | result = gNativeInputManager->getInputManager()->getReader()->hasKeys( |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 931 | deviceId, uint32_t(sourceMask), numCodes, codes, flags); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 932 | } else { |
| 933 | result = JNI_FALSE; |
| 934 | } |
| 935 | |
| 936 | env->ReleaseBooleanArrayElements(outFlags, flags, 0); |
| 937 | env->ReleaseIntArrayElements(keyCodes, codes, 0); |
| 938 | return result; |
| 939 | } |
| 940 | |
| 941 | static void throwInputChannelNotInitialized(JNIEnv* env) { |
| 942 | jniThrowException(env, "java/lang/IllegalStateException", |
| 943 | "inputChannel is not initialized"); |
| 944 | } |
| 945 | |
| 946 | static void android_server_InputManager_handleInputChannelDisposed(JNIEnv* env, |
| 947 | jobject inputChannelObj, const sp<InputChannel>& inputChannel, void* data) { |
| 948 | LOGW("Input channel object '%s' was disposed without first being unregistered with " |
| 949 | "the input manager!", inputChannel->getName().string()); |
| 950 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 951 | if (gNativeInputManager != NULL) { |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 952 | gNativeInputManager->unregisterInputChannel(env, inputChannel); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 953 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | static void android_server_InputManager_nativeRegisterInputChannel(JNIEnv* env, jclass clazz, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 957 | jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 958 | if (checkInputManagerUnitialized(env)) { |
| 959 | return; |
| 960 | } |
| 961 | |
| 962 | sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, |
| 963 | inputChannelObj); |
| 964 | if (inputChannel == NULL) { |
| 965 | throwInputChannelNotInitialized(env); |
| 966 | return; |
| 967 | } |
| 968 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 969 | sp<InputWindowHandle> inputWindowHandle = |
| 970 | android_server_InputWindowHandle_getHandle(env, inputWindowHandleObj); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 971 | |
| 972 | status_t status = gNativeInputManager->registerInputChannel( |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 973 | env, inputChannel, inputWindowHandle, monitor); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 974 | if (status) { |
| 975 | jniThrowRuntimeException(env, "Failed to register input channel. " |
| 976 | "Check logs for details."); |
| 977 | return; |
| 978 | } |
| 979 | |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 980 | if (! monitor) { |
| 981 | android_view_InputChannel_setDisposeCallback(env, inputChannelObj, |
| 982 | android_server_InputManager_handleInputChannelDisposed, NULL); |
| 983 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | static void android_server_InputManager_nativeUnregisterInputChannel(JNIEnv* env, jclass clazz, |
| 987 | jobject inputChannelObj) { |
| 988 | if (checkInputManagerUnitialized(env)) { |
| 989 | return; |
| 990 | } |
| 991 | |
| 992 | sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env, |
| 993 | inputChannelObj); |
| 994 | if (inputChannel == NULL) { |
| 995 | throwInputChannelNotInitialized(env); |
| 996 | return; |
| 997 | } |
| 998 | |
| 999 | android_view_InputChannel_setDisposeCallback(env, inputChannelObj, NULL, NULL); |
| 1000 | |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1001 | status_t status = gNativeInputManager->unregisterInputChannel(env, inputChannel); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1002 | if (status) { |
| 1003 | jniThrowRuntimeException(env, "Failed to unregister input channel. " |
| 1004 | "Check logs for details."); |
| 1005 | } |
| 1006 | } |
| 1007 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1008 | static jint android_server_InputManager_nativeInjectInputEvent(JNIEnv* env, jclass clazz, |
| 1009 | jobject inputEventObj, jint injectorPid, jint injectorUid, |
| 1010 | jint syncMode, jint timeoutMillis) { |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1011 | if (checkInputManagerUnitialized(env)) { |
| 1012 | return INPUT_EVENT_INJECTION_FAILED; |
| 1013 | } |
| 1014 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1015 | if (env->IsInstanceOf(inputEventObj, gKeyEventClassInfo.clazz)) { |
| 1016 | KeyEvent keyEvent; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1017 | status_t status = android_view_KeyEvent_toNative(env, inputEventObj, & keyEvent); |
| 1018 | if (status) { |
| 1019 | jniThrowRuntimeException(env, "Could not read contents of KeyEvent object."); |
| 1020 | return INPUT_EVENT_INJECTION_FAILED; |
| 1021 | } |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1022 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 1023 | return gNativeInputManager->getInputManager()->getDispatcher()->injectInputEvent( |
| 1024 | & keyEvent, injectorPid, injectorUid, syncMode, timeoutMillis); |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1025 | } else if (env->IsInstanceOf(inputEventObj, gMotionEventClassInfo.clazz)) { |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 1026 | const MotionEvent* motionEvent = android_view_MotionEvent_getNativePtr(env, inputEventObj); |
| 1027 | if (!motionEvent) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1028 | jniThrowRuntimeException(env, "Could not read contents of MotionEvent object."); |
| 1029 | return INPUT_EVENT_INJECTION_FAILED; |
| 1030 | } |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1031 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 1032 | return gNativeInputManager->getInputManager()->getDispatcher()->injectInputEvent( |
Jeff Brown | 2ed2462 | 2011-03-14 19:39:54 -0700 | [diff] [blame] | 1033 | motionEvent, injectorPid, injectorUid, syncMode, timeoutMillis); |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1034 | } else { |
| 1035 | jniThrowRuntimeException(env, "Invalid input event type."); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1036 | return INPUT_EVENT_INJECTION_FAILED; |
| 1037 | } |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1038 | } |
| 1039 | |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1040 | static void android_server_InputManager_nativeSetInputWindows(JNIEnv* env, jclass clazz, |
| 1041 | jobjectArray windowObjArray) { |
| 1042 | if (checkInputManagerUnitialized(env)) { |
| 1043 | return; |
| 1044 | } |
| 1045 | |
| 1046 | gNativeInputManager->setInputWindows(env, windowObjArray); |
| 1047 | } |
| 1048 | |
| 1049 | static void android_server_InputManager_nativeSetFocusedApplication(JNIEnv* env, jclass clazz, |
| 1050 | jobject applicationObj) { |
| 1051 | if (checkInputManagerUnitialized(env)) { |
| 1052 | return; |
| 1053 | } |
| 1054 | |
| 1055 | gNativeInputManager->setFocusedApplication(env, applicationObj); |
| 1056 | } |
| 1057 | |
| 1058 | static void android_server_InputManager_nativeSetInputDispatchMode(JNIEnv* env, |
| 1059 | jclass clazz, jboolean enabled, jboolean frozen) { |
| 1060 | if (checkInputManagerUnitialized(env)) { |
| 1061 | return; |
| 1062 | } |
| 1063 | |
| 1064 | gNativeInputManager->setInputDispatchMode(enabled, frozen); |
| 1065 | } |
| 1066 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 1067 | static void android_server_InputManager_nativeSetSystemUiVisibility(JNIEnv* env, |
| 1068 | jclass clazz, jint visibility) { |
| 1069 | if (checkInputManagerUnitialized(env)) { |
| 1070 | return; |
| 1071 | } |
| 1072 | |
| 1073 | gNativeInputManager->setSystemUiVisibility(visibility); |
| 1074 | } |
| 1075 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1076 | static jobject android_server_InputManager_nativeGetInputDevice(JNIEnv* env, |
| 1077 | jclass clazz, jint deviceId) { |
| 1078 | if (checkInputManagerUnitialized(env)) { |
| 1079 | return NULL; |
| 1080 | } |
| 1081 | |
| 1082 | InputDeviceInfo deviceInfo; |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 1083 | status_t status = gNativeInputManager->getInputManager()->getReader()->getInputDeviceInfo( |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1084 | deviceId, & deviceInfo); |
| 1085 | if (status) { |
| 1086 | return NULL; |
| 1087 | } |
| 1088 | |
| 1089 | jobject deviceObj = env->NewObject(gInputDeviceClassInfo.clazz, gInputDeviceClassInfo.ctor); |
| 1090 | if (! deviceObj) { |
| 1091 | return NULL; |
| 1092 | } |
| 1093 | |
| 1094 | jstring deviceNameObj = env->NewStringUTF(deviceInfo.getName().string()); |
| 1095 | if (! deviceNameObj) { |
| 1096 | return NULL; |
| 1097 | } |
| 1098 | |
| 1099 | env->SetIntField(deviceObj, gInputDeviceClassInfo.mId, deviceInfo.getId()); |
| 1100 | env->SetObjectField(deviceObj, gInputDeviceClassInfo.mName, deviceNameObj); |
| 1101 | env->SetIntField(deviceObj, gInputDeviceClassInfo.mSources, deviceInfo.getSources()); |
| 1102 | env->SetIntField(deviceObj, gInputDeviceClassInfo.mKeyboardType, deviceInfo.getKeyboardType()); |
| 1103 | |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 1104 | const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges(); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1105 | for (size_t i = 0; i < ranges.size(); i++) { |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 1106 | const InputDeviceInfo::MotionRange& range = ranges.itemAt(i); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1107 | env->CallVoidMethod(deviceObj, gInputDeviceClassInfo.addMotionRange, |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 1108 | range.axis, range.source, range.min, range.max, range.flat, range.fuzz); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1109 | if (env->ExceptionCheck()) { |
| 1110 | return NULL; |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | return deviceObj; |
| 1115 | } |
| 1116 | |
| 1117 | static jintArray android_server_InputManager_nativeGetInputDeviceIds(JNIEnv* env, |
| 1118 | jclass clazz) { |
| 1119 | if (checkInputManagerUnitialized(env)) { |
| 1120 | return NULL; |
| 1121 | } |
| 1122 | |
| 1123 | Vector<int> deviceIds; |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 1124 | gNativeInputManager->getInputManager()->getReader()->getInputDeviceIds(deviceIds); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1125 | |
| 1126 | jintArray deviceIdsObj = env->NewIntArray(deviceIds.size()); |
| 1127 | if (! deviceIdsObj) { |
| 1128 | return NULL; |
| 1129 | } |
| 1130 | |
| 1131 | env->SetIntArrayRegion(deviceIdsObj, 0, deviceIds.size(), deviceIds.array()); |
| 1132 | return deviceIdsObj; |
| 1133 | } |
| 1134 | |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1135 | static void android_server_InputManager_nativeGetInputConfiguration(JNIEnv* env, |
| 1136 | jclass clazz, jobject configObj) { |
| 1137 | if (checkInputManagerUnitialized(env)) { |
| 1138 | return; |
| 1139 | } |
| 1140 | |
| 1141 | InputConfiguration config; |
| 1142 | gNativeInputManager->getInputManager()->getReader()->getInputConfiguration(& config); |
| 1143 | |
| 1144 | env->SetIntField(configObj, gConfigurationClassInfo.touchscreen, config.touchScreen); |
| 1145 | env->SetIntField(configObj, gConfigurationClassInfo.keyboard, config.keyboard); |
| 1146 | env->SetIntField(configObj, gConfigurationClassInfo.navigation, config.navigation); |
| 1147 | } |
| 1148 | |
Jeff Brown | e650412 | 2010-09-27 14:52:15 -0700 | [diff] [blame] | 1149 | static jboolean android_server_InputManager_nativeTransferTouchFocus(JNIEnv* env, |
| 1150 | jclass clazz, jobject fromChannelObj, jobject toChannelObj) { |
| 1151 | if (checkInputManagerUnitialized(env)) { |
| 1152 | return false; |
| 1153 | } |
| 1154 | |
| 1155 | sp<InputChannel> fromChannel = |
| 1156 | android_view_InputChannel_getInputChannel(env, fromChannelObj); |
| 1157 | sp<InputChannel> toChannel = |
| 1158 | android_view_InputChannel_getInputChannel(env, toChannelObj); |
| 1159 | |
| 1160 | if (fromChannel == NULL || toChannel == NULL) { |
| 1161 | return false; |
| 1162 | } |
| 1163 | |
| 1164 | return gNativeInputManager->getInputManager()->getDispatcher()-> |
| 1165 | transferTouchFocus(fromChannel, toChannel); |
| 1166 | } |
| 1167 | |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 1168 | static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) { |
| 1169 | if (checkInputManagerUnitialized(env)) { |
| 1170 | return NULL; |
| 1171 | } |
| 1172 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 1173 | String8 dump; |
| 1174 | gNativeInputManager->dump(dump); |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 1175 | return env->NewStringUTF(dump.string()); |
| 1176 | } |
| 1177 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 1178 | // ---------------------------------------------------------------------------- |
| 1179 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1180 | static JNINativeMethod gInputManagerMethods[] = { |
| 1181 | /* name, signature, funcPtr */ |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 1182 | { "nativeInit", "(Lcom/android/server/wm/InputManager$Callbacks;Landroid/os/MessageQueue;)V", |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1183 | (void*) android_server_InputManager_nativeInit }, |
| 1184 | { "nativeStart", "()V", |
| 1185 | (void*) android_server_InputManager_nativeStart }, |
| 1186 | { "nativeSetDisplaySize", "(III)V", |
| 1187 | (void*) android_server_InputManager_nativeSetDisplaySize }, |
| 1188 | { "nativeSetDisplayOrientation", "(II)V", |
| 1189 | (void*) android_server_InputManager_nativeSetDisplayOrientation }, |
| 1190 | { "nativeGetScanCodeState", "(III)I", |
| 1191 | (void*) android_server_InputManager_nativeGetScanCodeState }, |
| 1192 | { "nativeGetKeyCodeState", "(III)I", |
| 1193 | (void*) android_server_InputManager_nativeGetKeyCodeState }, |
| 1194 | { "nativeGetSwitchState", "(III)I", |
| 1195 | (void*) android_server_InputManager_nativeGetSwitchState }, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1196 | { "nativeHasKeys", "(II[I[Z)Z", |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1197 | (void*) android_server_InputManager_nativeHasKeys }, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 1198 | { "nativeRegisterInputChannel", |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1199 | "(Landroid/view/InputChannel;Lcom/android/server/wm/InputWindowHandle;Z)V", |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1200 | (void*) android_server_InputManager_nativeRegisterInputChannel }, |
| 1201 | { "nativeUnregisterInputChannel", "(Landroid/view/InputChannel;)V", |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1202 | (void*) android_server_InputManager_nativeUnregisterInputChannel }, |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1203 | { "nativeInjectInputEvent", "(Landroid/view/InputEvent;IIII)I", |
| 1204 | (void*) android_server_InputManager_nativeInjectInputEvent }, |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1205 | { "nativeSetInputWindows", "([Lcom/android/server/wm/InputWindow;)V", |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1206 | (void*) android_server_InputManager_nativeSetInputWindows }, |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1207 | { "nativeSetFocusedApplication", "(Lcom/android/server/wm/InputApplication;)V", |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1208 | (void*) android_server_InputManager_nativeSetFocusedApplication }, |
| 1209 | { "nativeSetInputDispatchMode", "(ZZ)V", |
| 1210 | (void*) android_server_InputManager_nativeSetInputDispatchMode }, |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 1211 | { "nativeSetSystemUiVisibility", "(I)V", |
| 1212 | (void*) android_server_InputManager_nativeSetSystemUiVisibility }, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1213 | { "nativeGetInputDevice", "(I)Landroid/view/InputDevice;", |
| 1214 | (void*) android_server_InputManager_nativeGetInputDevice }, |
| 1215 | { "nativeGetInputDeviceIds", "()[I", |
| 1216 | (void*) android_server_InputManager_nativeGetInputDeviceIds }, |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1217 | { "nativeGetInputConfiguration", "(Landroid/content/res/Configuration;)V", |
| 1218 | (void*) android_server_InputManager_nativeGetInputConfiguration }, |
Jeff Brown | e650412 | 2010-09-27 14:52:15 -0700 | [diff] [blame] | 1219 | { "nativeTransferTouchFocus", "(Landroid/view/InputChannel;Landroid/view/InputChannel;)Z", |
| 1220 | (void*) android_server_InputManager_nativeTransferTouchFocus }, |
Jeff Brown | e33348b | 2010-07-15 23:54:05 -0700 | [diff] [blame] | 1221 | { "nativeDump", "()Ljava/lang/String;", |
| 1222 | (void*) android_server_InputManager_nativeDump }, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1223 | }; |
| 1224 | |
| 1225 | #define FIND_CLASS(var, className) \ |
| 1226 | var = env->FindClass(className); \ |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1227 | LOG_FATAL_IF(! var, "Unable to find class " className); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1228 | |
| 1229 | #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \ |
| 1230 | var = env->GetMethodID(clazz, methodName, methodDescriptor); \ |
| 1231 | LOG_FATAL_IF(! var, "Unable to find method " methodName); |
| 1232 | |
| 1233 | #define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \ |
| 1234 | var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \ |
| 1235 | LOG_FATAL_IF(! var, "Unable to find field " fieldName); |
| 1236 | |
| 1237 | int register_android_server_InputManager(JNIEnv* env) { |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1238 | int res = jniRegisterNativeMethods(env, "com/android/server/wm/InputManager", |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1239 | gInputManagerMethods, NELEM(gInputManagerMethods)); |
| 1240 | LOG_FATAL_IF(res < 0, "Unable to register native methods."); |
| 1241 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 1242 | // Callbacks |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1243 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1244 | jclass clazz; |
| 1245 | FIND_CLASS(clazz, "com/android/server/wm/InputManager$Callbacks"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1246 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1247 | GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, clazz, |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1248 | "notifyConfigurationChanged", "(J)V"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1249 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1250 | GET_METHOD_ID(gCallbacksClassInfo.notifyLidSwitchChanged, clazz, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1251 | "notifyLidSwitchChanged", "(JZ)V"); |
| 1252 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1253 | GET_METHOD_ID(gCallbacksClassInfo.notifyInputChannelBroken, clazz, |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1254 | "notifyInputChannelBroken", "(Lcom/android/server/wm/InputWindowHandle;)V"); |
Jeff Brown | 7fbdc84 | 2010-06-17 20:52:56 -0700 | [diff] [blame] | 1255 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1256 | GET_METHOD_ID(gCallbacksClassInfo.notifyANR, clazz, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 1257 | "notifyANR", |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1258 | "(Lcom/android/server/wm/InputApplicationHandle;Lcom/android/server/wm/InputWindowHandle;)J"); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1259 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1260 | GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeQueueing, clazz, |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1261 | "interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;IZ)I"); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1262 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1263 | GET_METHOD_ID(gCallbacksClassInfo.interceptMotionBeforeQueueingWhenScreenOff, |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1264 | clazz, |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1265 | "interceptMotionBeforeQueueingWhenScreenOff", "(I)I"); |
| 1266 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1267 | GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeDispatching, clazz, |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1268 | "interceptKeyBeforeDispatching", |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1269 | "(Lcom/android/server/wm/InputWindowHandle;Landroid/view/KeyEvent;I)Z"); |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1270 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1271 | GET_METHOD_ID(gCallbacksClassInfo.dispatchUnhandledKey, clazz, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1272 | "dispatchUnhandledKey", |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1273 | "(Lcom/android/server/wm/InputWindowHandle;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;"); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1274 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1275 | GET_METHOD_ID(gCallbacksClassInfo.checkInjectEventsPermission, clazz, |
Jeff Brown | 349703e | 2010-06-22 01:27:15 -0700 | [diff] [blame] | 1276 | "checkInjectEventsPermission", "(II)Z"); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1277 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1278 | GET_METHOD_ID(gCallbacksClassInfo.filterTouchEvents, clazz, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1279 | "filterTouchEvents", "()Z"); |
| 1280 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1281 | GET_METHOD_ID(gCallbacksClassInfo.filterJumpyTouchEvents, clazz, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1282 | "filterJumpyTouchEvents", "()Z"); |
| 1283 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1284 | GET_METHOD_ID(gCallbacksClassInfo.getVirtualKeyQuietTimeMillis, clazz, |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 1285 | "getVirtualKeyQuietTimeMillis", "()I"); |
| 1286 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1287 | GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, clazz, |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1288 | "getExcludedDeviceNames", "()[Ljava/lang/String;"); |
| 1289 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1290 | GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatTimeout, clazz, |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 1291 | "getKeyRepeatTimeout", "()I"); |
| 1292 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1293 | GET_METHOD_ID(gCallbacksClassInfo.getKeyRepeatDelay, clazz, |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 1294 | "getKeyRepeatDelay", "()I"); |
| 1295 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1296 | GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, clazz, |
Jeff Brown | ae9fc03 | 2010-08-18 15:51:08 -0700 | [diff] [blame] | 1297 | "getMaxEventsPerSecond", "()I"); |
| 1298 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1299 | GET_METHOD_ID(gCallbacksClassInfo.getPointerLayer, clazz, |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 1300 | "getPointerLayer", "()I"); |
| 1301 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1302 | GET_METHOD_ID(gCallbacksClassInfo.getPointerIcon, clazz, |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 1303 | "getPointerIcon", "()Lcom/android/server/wm/InputManager$PointerIcon;"); |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1304 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1305 | // KeyEvent |
| 1306 | |
| 1307 | FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1308 | gKeyEventClassInfo.clazz = jclass(env->NewGlobalRef(gKeyEventClassInfo.clazz)); |
| 1309 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1310 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1311 | // MotionEvent |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1312 | |
| 1313 | FIND_CLASS(gMotionEventClassInfo.clazz, "android/view/MotionEvent"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1314 | gMotionEventClassInfo.clazz = jclass(env->NewGlobalRef(gMotionEventClassInfo.clazz)); |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 1315 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1316 | // InputDevice |
| 1317 | |
| 1318 | FIND_CLASS(gInputDeviceClassInfo.clazz, "android/view/InputDevice"); |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1319 | gInputDeviceClassInfo.clazz = jclass(env->NewGlobalRef(gInputDeviceClassInfo.clazz)); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1320 | |
| 1321 | GET_METHOD_ID(gInputDeviceClassInfo.ctor, gInputDeviceClassInfo.clazz, |
| 1322 | "<init>", "()V"); |
| 1323 | |
| 1324 | GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz, |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 1325 | "addMotionRange", "(IIFFFF)V"); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1326 | |
| 1327 | GET_FIELD_ID(gInputDeviceClassInfo.mId, gInputDeviceClassInfo.clazz, |
| 1328 | "mId", "I"); |
| 1329 | |
| 1330 | GET_FIELD_ID(gInputDeviceClassInfo.mName, gInputDeviceClassInfo.clazz, |
| 1331 | "mName", "Ljava/lang/String;"); |
| 1332 | |
| 1333 | GET_FIELD_ID(gInputDeviceClassInfo.mSources, gInputDeviceClassInfo.clazz, |
| 1334 | "mSources", "I"); |
| 1335 | |
| 1336 | GET_FIELD_ID(gInputDeviceClassInfo.mKeyboardType, gInputDeviceClassInfo.clazz, |
| 1337 | "mKeyboardType", "I"); |
| 1338 | |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1339 | // Configuration |
| 1340 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1341 | FIND_CLASS(clazz, "android/content/res/Configuration"); |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1342 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1343 | GET_FIELD_ID(gConfigurationClassInfo.touchscreen, clazz, |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1344 | "touchscreen", "I"); |
| 1345 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1346 | GET_FIELD_ID(gConfigurationClassInfo.keyboard, clazz, |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1347 | "keyboard", "I"); |
| 1348 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1349 | GET_FIELD_ID(gConfigurationClassInfo.navigation, clazz, |
Jeff Brown | 57c5937 | 2010-09-21 18:22:55 -0700 | [diff] [blame] | 1350 | "navigation", "I"); |
| 1351 | |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1352 | // PointerIcon |
| 1353 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1354 | FIND_CLASS(clazz, "com/android/server/wm/InputManager$PointerIcon"); |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1355 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1356 | GET_FIELD_ID(gPointerIconClassInfo.bitmap, clazz, |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1357 | "bitmap", "Landroid/graphics/Bitmap;"); |
| 1358 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1359 | GET_FIELD_ID(gPointerIconClassInfo.hotSpotX, clazz, |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1360 | "hotSpotX", "F"); |
| 1361 | |
Carl Shapiro | 17cc33a | 2011-03-05 20:53:16 -0800 | [diff] [blame] | 1362 | GET_FIELD_ID(gPointerIconClassInfo.hotSpotY, clazz, |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 1363 | "hotSpotY", "F"); |
| 1364 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1365 | return 0; |
| 1366 | } |
| 1367 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1368 | } /* namespace android */ |