diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-11-30 19:23:22 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-12-01 14:13:48 -0800 |
commit | 4952dfd16a0f839559ffa78f5016394caf85294f (patch) | |
tree | d79061d9e6ceb2671241a059fe6be9522c8bbb10 /core/jni/android_view_InputQueue.cpp | |
parent | 95db2b20d7bc0aaf00b1d4418124f5cf0a755d74 (diff) | |
download | frameworks_base-4952dfd16a0f839559ffa78f5016394caf85294f.zip frameworks_base-4952dfd16a0f839559ffa78f5016394caf85294f.tar.gz frameworks_base-4952dfd16a0f839559ffa78f5016394caf85294f.tar.bz2 |
Ensure input events are processed in-order in the application.
As it turns out, it used to be possible for there to be multiple
input events simultaneously in flight in an application. Although
it worked, it made it hard to reason about what was going on.
The problem was somewhat exacerbated by the introduction of a
queue of "InputEventMessage" objects as part of an earlier latency
optimization.
This change restores order from chaos and greatly simplifies the
invariants related to input event dispatch within the application.
Change-Id: I6de5fe61c1fe2ac3dd33edf770d949044df8a019
Diffstat (limited to 'core/jni/android_view_InputQueue.cpp')
-rw-r--r-- | core/jni/android_view_InputQueue.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp index 300c04a..549f575 100644 --- a/core/jni/android_view_InputQueue.cpp +++ b/core/jni/android_view_InputQueue.cpp @@ -45,8 +45,7 @@ namespace android { static struct { jclass clazz; - jmethodID dispatchKeyEvent; - jmethodID dispatchMotionEvent; + jmethodID dispatchInputEvent; } gInputQueueClassInfo; // ---------------------------------------------------------------------------- @@ -365,7 +364,6 @@ int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* dat int32_t inputEventType = inputEvent->getType(); jobject inputEventObj; - jmethodID dispatchMethodId; switch (inputEventType) { case AINPUT_EVENT_TYPE_KEY: #if DEBUG_DISPATCH_CYCLE @@ -373,7 +371,6 @@ int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* dat #endif inputEventObj = android_view_KeyEvent_fromNative(env, static_cast<KeyEvent*>(inputEvent)); - dispatchMethodId = gInputQueueClassInfo.dispatchKeyEvent; break; case AINPUT_EVENT_TYPE_MOTION: @@ -382,7 +379,6 @@ int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* dat #endif inputEventObj = android_view_MotionEvent_obtainAsCopy(env, static_cast<MotionEvent*>(inputEvent)); - dispatchMethodId = gInputQueueClassInfo.dispatchMotionEvent; break; default: @@ -402,7 +398,7 @@ int NativeInputQueue::handleReceiveCallback(int receiveFd, int events, void* dat LOGD("Invoking input handler."); #endif env->CallStaticVoidMethod(gInputQueueClassInfo.clazz, - dispatchMethodId, inputHandlerObjLocal, inputEventObj, + gInputQueueClassInfo.dispatchInputEvent, inputHandlerObjLocal, inputEventObj, jlong(finishedToken)); #if DEBUG_DISPATCH_CYCLE LOGD("Returned from input handler."); @@ -517,13 +513,9 @@ int register_android_view_InputQueue(JNIEnv* env) { FIND_CLASS(gInputQueueClassInfo.clazz, "android/view/InputQueue"); - GET_STATIC_METHOD_ID(gInputQueueClassInfo.dispatchKeyEvent, gInputQueueClassInfo.clazz, - "dispatchKeyEvent", - "(Landroid/view/InputHandler;Landroid/view/KeyEvent;J)V"); - - GET_STATIC_METHOD_ID(gInputQueueClassInfo.dispatchMotionEvent, gInputQueueClassInfo.clazz, - "dispatchMotionEvent", - "(Landroid/view/InputHandler;Landroid/view/MotionEvent;J)V"); + GET_STATIC_METHOD_ID(gInputQueueClassInfo.dispatchInputEvent, gInputQueueClassInfo.clazz, + "dispatchInputEvent", + "(Landroid/view/InputHandler;Landroid/view/InputEvent;J)V"); return 0; } |