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

Commit e62aa485 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use IBinder pointer when hashing in InputTransferToken." into main

parents 4f8e872d fc2e363d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public final class InputTransferToken implements Parcelable {
    private static native void nativeWriteToParcel(long nativeObject, Parcel out);
    private static native long nativeReadFromParcel(Parcel in);
    private static native IBinder nativeGetBinderToken(long nativeObject);
    private static native long nativeGetBinderTokenRef(long nativeObject);
    private static native long nativeGetNativeInputTransferTokenFinalizer();
    private static native boolean nativeEquals(long nativeObject1, long nativeObject2);

@@ -130,7 +131,7 @@ public final class InputTransferToken implements Parcelable {
     */
    @Override
    public int hashCode() {
        return Objects.hash(getToken());
        return Objects.hash(nativeGetBinderTokenRef(mNativeObject));
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ static jobject nativeGetBinderToken(JNIEnv* env, jclass clazz, jlong nativeObj)
    return javaObjectForIBinder(env, inputTransferToken->mToken);
}

static jlong nativeGetBinderTokenRef(JNIEnv*, jclass, jlong nativeObj) {
    sp<InputTransferToken> inputTransferToken = reinterpret_cast<InputTransferToken*>(nativeObj);
    return reinterpret_cast<jlong>(inputTransferToken->mToken.get());
}

InputTransferToken* android_window_InputTransferToken_getNativeInputTransferToken(
        JNIEnv* env, jobject inputTransferTokenObj) {
    if (inputTransferTokenObj != nullptr &&
@@ -114,6 +119,7 @@ static const JNINativeMethod sInputTransferTokenMethods[] = {
    {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel},
    {"nativeReadFromParcel", "(Landroid/os/Parcel;)J", (void*)nativeReadFromParcel},
    {"nativeGetBinderToken", "(J)Landroid/os/IBinder;", (void*)nativeGetBinderToken},
    {"nativeGetBinderTokenRef", "(J)J", (void*)nativeGetBinderTokenRef},
    {"nativeGetNativeInputTransferTokenFinalizer", "()J", (void*)nativeGetNativeInputTransferTokenFinalizer},
        {"nativeEquals", "(JJ)Z", (void*) nativeEquals},
        // clang-format on