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

Commit 86df7e42 authored by Jim Blackler's avatar Jim Blackler
Browse files

Give access to the native InputQueue to all native applications.

Bug: 116830907
Test: atest android.view.cts.InputQueueTest#testNativeInputQueue
Change-Id: Ia7741ac4922afeeca334266caef3331b521f87e4
parent e461cc6e
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;