diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-07-16 15:38:03 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-07-16 15:41:07 -0700 |
commit | ace999b096739d376d4845c0ba94599197ff8477 (patch) | |
tree | 5ad20b0abce784865b3c0d27563257a96dc07ae6 /core | |
parent | b6761e73ce6b255cfe96bfa1fa6ac611abcfc067 (diff) | |
download | frameworks_base-ace999b096739d376d4845c0ba94599197ff8477.zip frameworks_base-ace999b096739d376d4845c0ba94599197ff8477.tar.gz frameworks_base-ace999b096739d376d4845c0ba94599197ff8477.tar.bz2 |
Ignore attempts to finish events on unregistered channels.
This is a common race that happens during application shutdown where the window
may be removed before the input event is finished. The input dispatcher
already recovers from this condition gracefully so there are no benefits to
throwing an exception on the client side.
Bug: 2834068
Change-Id: I53dcc3230464d7f528ac8a1cc9f01b5bb642f428
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_view_InputQueue.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp index 226c797..556d367 100644 --- a/core/jni/android_view_InputQueue.cpp +++ b/core/jni/android_view_InputQueue.cpp @@ -413,6 +413,7 @@ static void android_view_InputQueue_nativeRegisterInputChannel(JNIEnv* env, jcla jobject inputChannelObj, jobject inputHandlerObj, jobject messageQueueObj) { status_t status = gNativeInputQueue.registerInputChannel( env, inputChannelObj, inputHandlerObj, messageQueueObj); + if (status) { jniThrowRuntimeException(env, "Failed to register input channel. " "Check logs for details."); @@ -422,6 +423,7 @@ static void android_view_InputQueue_nativeRegisterInputChannel(JNIEnv* env, jcla static void android_view_InputQueue_nativeUnregisterInputChannel(JNIEnv* env, jclass clazz, jobject inputChannelObj) { status_t status = gNativeInputQueue.unregisterInputChannel(env, inputChannelObj); + if (status) { jniThrowRuntimeException(env, "Failed to unregister input channel. " "Check logs for details."); @@ -432,7 +434,11 @@ static void android_view_InputQueue_nativeFinished(JNIEnv* env, jclass clazz, jlong finishedToken) { status_t status = gNativeInputQueue.finished( env, finishedToken, false /*ignoreSpuriousFinish*/); - if (status) { + + // We ignore the case where an event could not be finished because the input channel + // was no longer registered (DEAD_OBJECT) since it is a common race that can occur + // during application shutdown. The input dispatcher recovers gracefully anyways. + if (status != OK && status != DEAD_OBJECT) { jniThrowRuntimeException(env, "Failed to finish input event. " "Check logs for details."); } |