Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a706bc6 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Correctly manage the lifecycle of IME InputChannels." into jb-mr2-dev

parents 5feceebb 1951ce86
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -153,6 +153,14 @@ public class Binder implements IBinder {
     */
    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.
     */
+11 −1
Original line number Diff line number Diff line
@@ -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();

@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public final class InputBindResult implements Parcelable {
        dest.writeStrongInterface(method);
        if (channel != null) {
            dest.writeInt(1);
            channel.writeToParcel(dest, 0);
            channel.writeToParcel(dest, flags);
        } else {
            dest.writeInt(0);
        }
+11 −0
Original line number Diff line number Diff line
@@ -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) \
+3 −0
Original line number Diff line number Diff line
@@ -168,6 +168,9 @@ public:
     */
    status_t receiveMessage(InputMessage* msg);

    /* Returns a new object that has a duplicate of this channel's fd. */
    sp<InputChannel> dup() const;

private:
    String8 mName;
    int mFd;
Loading