diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-06-30 15:33:41 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-06-30 15:33:41 -0700 |
commit | 0c2df98425c8fa4ce092eebea80ae197547f6a86 (patch) | |
tree | 7466cf97f4dc70049769cac97b9be9b299b96a46 /services | |
parent | 705a2df97c51c3e31ed36831a4302d705e0532b2 (diff) | |
parent | d8ae28854e1ed9bd90d7407f94c2e5ed9028b712 (diff) | |
download | frameworks_base-0c2df98425c8fa4ce092eebea80ae197547f6a86.zip frameworks_base-0c2df98425c8fa4ce092eebea80ae197547f6a86.tar.gz frameworks_base-0c2df98425c8fa4ce092eebea80ae197547f6a86.tar.bz2 |
am d8ae2885: Merge "Fix injection of specially intercepted keys like HOME." into gingerbread
Merge commit 'd8ae28854e1ed9bd90d7407f94c2e5ed9028b712' into gingerbread-plus-aosp
* commit 'd8ae28854e1ed9bd90d7407f94c2e5ed9028b712':
Fix injection of specially intercepted keys like HOME.
Diffstat (limited to 'services')
-rw-r--r-- | services/jni/com_android_server_InputManager.cpp | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp index 7f245f3..d0f856b 100644 --- a/services/jni/com_android_server_InputManager.cpp +++ b/services/jni/com_android_server_InputManager.cpp @@ -374,6 +374,9 @@ private: int32_t identifyTouchEventTargets(MotionEvent* motionEvent, uint32_t policyFlags, int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets); + bool interceptKeyBeforeDispatching(const InputTarget& target, + const KeyEvent* keyEvent, uint32_t policyFlags); + void pokeUserActivityIfNeeded(int32_t windowType, int32_t eventType); void pokeUserActivity(nsecs_t eventTime, int32_t eventType); bool checkInjectionPermission(const InputWindow* window, @@ -633,8 +636,6 @@ int32_t NativeInputManager::interceptKey(nsecs_t when, } } - // TODO Be smarter about which keys cause us to request interception during dispatch. - actions |= InputReaderPolicyInterface::ACTION_INTERCEPT_DISPATCH; return actions; } @@ -1530,34 +1531,11 @@ int32_t NativeInputManager::waitForKeyEventTargets(KeyEvent* keyEvent, uint32_t windowType = focusedWindow->layoutParamsType; } // release lock - if (policyFlags & POLICY_FLAG_INTERCEPT_DISPATCH) { - const InputTarget& target = outTargets.top(); - - JNIEnv* env = jniEnv(); - - jobject inputChannelObj = getInputChannelObjLocal(env, target.inputChannel); - if (inputChannelObj) { - jboolean consumed = env->CallBooleanMethod(mCallbacksObj, - gCallbacksClassInfo.interceptKeyBeforeDispatching, - inputChannelObj, keyEvent->getKeyCode(), keyEvent->getMetaState(), - keyEvent->getAction() == KEY_EVENT_ACTION_DOWN, - keyEvent->getRepeatCount(), policyFlags); - bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatch"); - - env->DeleteLocalRef(inputChannelObj); - - if (error) { - return INPUT_EVENT_INJECTION_FAILED; - } - - if (consumed) { - outTargets.clear(); - return INPUT_EVENT_INJECTION_SUCCEEDED; - } - } else { - LOGW("Could not apply key dispatch policy because input channel '%s' is " - "no longer valid.", target.inputChannel->getName().string()); - } + const InputTarget& target = outTargets.top(); + bool consumed = interceptKeyBeforeDispatching(target, keyEvent, policyFlags); + if (consumed) { + outTargets.clear(); + return INPUT_EVENT_INJECTION_SUCCEEDED; } pokeUserActivityIfNeeded(windowType, POWER_MANAGER_BUTTON_EVENT); @@ -1656,6 +1634,29 @@ int32_t NativeInputManager::identifyTouchEventTargets(MotionEvent* motionEvent, return INPUT_EVENT_INJECTION_SUCCEEDED; } +bool NativeInputManager::interceptKeyBeforeDispatching(const InputTarget& target, + const KeyEvent* keyEvent, uint32_t policyFlags) { + JNIEnv* env = jniEnv(); + + jobject inputChannelObj = getInputChannelObjLocal(env, target.inputChannel); + if (inputChannelObj) { + jboolean consumed = env->CallBooleanMethod(mCallbacksObj, + gCallbacksClassInfo.interceptKeyBeforeDispatching, + inputChannelObj, keyEvent->getKeyCode(), keyEvent->getMetaState(), + keyEvent->getAction() == KEY_EVENT_ACTION_DOWN, + keyEvent->getRepeatCount(), policyFlags); + bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching"); + + env->DeleteLocalRef(inputChannelObj); + + return consumed && ! error; + } else { + LOGW("Could not apply key dispatch policy because input channel '%s' is " + "no longer valid.", target.inputChannel->getName().string()); + return false; + } +} + void NativeInputManager::pokeUserActivityIfNeeded(int32_t windowType, int32_t eventType) { if (windowType != TYPE_KEYGUARD) { nsecs_t eventTime = now(); |