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

Commit 13b49135 authored by Jim Blackler's avatar Jim Blackler Committed by Android (Google) Code Review
Browse files

Merge "Give access to the native InputQueue to all native applications."

parents 93c91bea 86df7e42
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ namespace android {

static struct {
    jmethodID finishInputEvent;
    jmethodID getNativePtr;
} gInputQueueClassInfo;

enum {
@@ -263,8 +264,15 @@ int register_android_view_InputQueue(JNIEnv* env)
    jclass clazz = FindClassOrDie(env, kInputQueuePathName);
    gInputQueueClassInfo.finishInputEvent = GetMethodIDOrDie(env, clazz, "finishInputEvent",
                                                             "(JZ)V");
    gInputQueueClassInfo.getNativePtr = GetMethodIDOrDie(env, clazz, "getNativePtr", "()J");

    return RegisterMethodsOrDie(env, kInputQueuePathName, g_methods, NELEM(g_methods));
}

AInputQueue* android_view_InputQueue_getNativePtr(jobject inputQueue) {
    JNIEnv* env = AndroidRuntime::getJNIEnv();
    jlong ptr = env->CallLongMethod(inputQueue, gInputQueueClassInfo.getNativePtr);
    return reinterpret_cast<AInputQueue*>(ptr);
}

} // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ private:
    Vector<key_value_pair_t<InputEvent*, bool> > mFinishedEvents;
};

extern AInputQueue* android_view_InputQueue_getNativePtr(jobject inputQueue);

} // namespace android

#endif
+4 −0
Original line number Diff line number Diff line
@@ -329,3 +329,7 @@ void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled
    InputEvent* e = static_cast<InputEvent*>(event);
    iq->finishEvent(e, handled != 0);
}

AInputQueue* AInputQueue_fromJava(jobject inputQueue) {
    return android::android_view_InputQueue_getNativePtr(inputQueue);
}
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ LIBANDROID {
    AInputQueue_attachLooper;
    AInputQueue_detachLooper;
    AInputQueue_finishEvent;
    AInputQueue_fromJava; # introduced=Tiramisu
    AInputQueue_getEvent;
    AInputQueue_hasEvents;
    AInputQueue_preDispatchEvent;