summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2013-04-04 22:45:12 -0700
committerJeff Brown <jeffbrown@google.com>2013-04-04 22:45:12 -0700
commit1951ce86c21445ac191e4d2d95233f4f5c096b56 (patch)
tree8c68eb0fe87565bcdaf7cd8bd2a56a03319bede5 /core/java/android
parent41c076715da58990dc9b0be749bba28fc75d3b78 (diff)
downloadframeworks_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/java/android')
-rw-r--r--core/java/android/os/Binder.java10
-rw-r--r--core/java/android/view/InputChannel.java12
2 files changed, 20 insertions, 2 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 16b4835..e9e7551 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -152,7 +152,15 @@ public class Binder implements IBinder {
* not return until the current process is exiting.
*/
public static final native void joinThreadPool();
-
+
+ /**
+ * Returns true if the specified interface is a proxy.
+ * @hide
+ */
+ public static final boolean isProxy(IInterface iface) {
+ return iface.asBinder() != iface;
+ }
+
/**
* Default constructor initializes the object.
*/
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index a797176..40ee1ad 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -54,6 +54,7 @@ public final class InputChannel implements Parcelable {
private native void nativeTransferTo(InputChannel other);
private native void nativeReadFromParcel(Parcel parcel);
private native void nativeWriteToParcel(Parcel parcel);
+ private native void nativeDup(InputChannel target);
private native String nativeGetName();
@@ -64,7 +65,7 @@ public final class InputChannel implements Parcelable {
*/
public InputChannel() {
}
-
+
@Override
protected void finalize() throws Throwable {
try {
@@ -125,6 +126,15 @@ public final class InputChannel implements Parcelable {
nativeTransferTo(outParameter);
}
+ /**
+ * Duplicates the input channel.
+ */
+ public InputChannel dup() {
+ InputChannel target = new InputChannel();
+ nativeDup(target);
+ return target;
+ }
+
@Override
public int describeContents() {
return Parcelable.CONTENTS_FILE_DESCRIPTOR;