diff options
author | Jeff Brown <jeffbrown@google.com> | 2013-04-04 22:45:12 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2013-04-04 22:45:12 -0700 |
commit | 1951ce86c21445ac191e4d2d95233f4f5c096b56 (patch) | |
tree | 8c68eb0fe87565bcdaf7cd8bd2a56a03319bede5 /core/jni/android_view_InputChannel.cpp | |
parent | 41c076715da58990dc9b0be749bba28fc75d3b78 (diff) | |
download | frameworks_base-1951ce86c21445ac191e4d2d95233f4f5c096b56.zip frameworks_base-1951ce86c21445ac191e4d2d95233f4f5c096b56.tar.gz frameworks_base-1951ce86c21445ac191e4d2d95233f4f5c096b56.tar.bz2 |
Correctly manage the lifecycle of IME InputChannels.
InputChannels are normally duplicated when sent to a remote process
over Binder but this does not happen if the recipient is running within
the system server process. This causes problems for KeyGuard because the
InputMethodManagerService may accidentally dispose the channel
that KeyGuard is using.
Fixed the lifecycle of InputChannels that are managed by the IME
framework. We now return a duplicate of the channel to the application
and then take care to dispose of the duplicate when necessary.
In particular, InputBindResult disposes its InputChannel automatically
when returned through Binder (using PARCELABLE_WRITE_RETURN_VALUE).
Bug: 8493879
Change-Id: I08ec3d13268c76f3b56706b4523508bcefa3be79
Diffstat (limited to 'core/jni/android_view_InputChannel.cpp')
-rw-r--r-- | core/jni/android_view_InputChannel.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp index 9c44a59..9fa9fe4 100644 --- a/core/jni/android_view_InputChannel.cpp +++ b/core/jni/android_view_InputChannel.cpp @@ -246,6 +246,15 @@ static jstring android_view_InputChannel_nativeGetName(JNIEnv* env, jobject obj) return name; } +static void android_view_InputChannel_nativeDup(JNIEnv* env, jobject obj, jobject otherObj) { + NativeInputChannel* nativeInputChannel = + android_view_InputChannel_getNativeInputChannel(env, obj); + if (nativeInputChannel) { + android_view_InputChannel_setNativeInputChannel(env, otherObj, + new NativeInputChannel(nativeInputChannel->getInputChannel()->dup())); + } +} + // ---------------------------------------------------------------------------- static JNINativeMethod gInputChannelMethods[] = { @@ -262,6 +271,8 @@ static JNINativeMethod gInputChannelMethods[] = { (void*)android_view_InputChannel_nativeWriteToParcel }, { "nativeGetName", "()Ljava/lang/String;", (void*)android_view_InputChannel_nativeGetName }, + { "nativeDup", "(Landroid/view/InputChannel;)V", + (void*)android_view_InputChannel_nativeDup }, }; #define FIND_CLASS(var, className) \ |