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

Commit 047790a4 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Simplify creation of NativeInputChannel

We don't need to create an object just to pass it to the function.
The target function can do it by itself.
This change will enable opening up
android_view_InputChannel_createInputChannel to the
com_android.._InputManagerService, which will allow the InputManager to
create InputChannel objects.

Bug: 142581626
Test: presubmit
Change-Id: Ide6ba9d88b209f33a0161c61cc49f4e02b8ed486
parent 97fffca6
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -112,7 +112,9 @@ void android_view_InputChannel_setDisposeCallback(JNIEnv* env, jobject inputChan
}

static jobject android_view_InputChannel_createInputChannel(JNIEnv* env,
        std::unique_ptr<NativeInputChannel> nativeInputChannel) {
        sp<InputChannel> inputChannel) {
    std::unique_ptr<NativeInputChannel> nativeInputChannel =
            std::make_unique<NativeInputChannel>(inputChannel);
    jobject inputChannelObj = env->NewObject(gInputChannelClassInfo.clazz,
            gInputChannelClassInfo.ctor);
    if (inputChannelObj) {
@@ -143,14 +145,12 @@ static jobjectArray android_view_InputChannel_nativeOpenInputChannelPair(JNIEnv*
        return nullptr;
    }

    jobject serverChannelObj = android_view_InputChannel_createInputChannel(env,
            std::make_unique<NativeInputChannel>(serverChannel));
    jobject serverChannelObj = android_view_InputChannel_createInputChannel(env, serverChannel);
    if (env->ExceptionCheck()) {
        return nullptr;
    }

    jobject clientChannelObj = android_view_InputChannel_createInputChannel(env,
            std::make_unique<NativeInputChannel>(clientChannel));
    jobject clientChannelObj = android_view_InputChannel_createInputChannel(env, clientChannel);
    if (env->ExceptionCheck()) {
        return nullptr;
    }