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

Commit 5e70aa55 authored by chaviw's avatar chaviw Committed by Chavi Weingarten
Browse files

Add ScopedLocalFrame in functions that hold Java objects

In order to make sure all the Java objects are cleaned up, add
ScopedLocalFrame in each function that converts native objects to Java.
This will make sure any local object will be cleaned up.

Test: Builds
Bug: 225287201
Change-Id: I4264d3869409597c44bcf897e4ebeae0660f252b
parent 6d1be01f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <gui/DisplayInfo.h>
#include <gui/SurfaceComposerClient.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedLocalFrame.h>
#include <utils/Log.h>

#include "android_hardware_input_InputWindowHandle.h"
@@ -95,6 +96,7 @@ struct WindowInfosListener : public gui::WindowInfosListener {
        JNIEnv* env = AndroidRuntime::getJNIEnv();
        LOG_ALWAYS_FATAL_IF(env == nullptr, "Unable to retrieve JNIEnv in onWindowInfoChanged.");

        ScopedLocalFrame localFrame(env);
        jobject listener = env->NewGlobalRef(mListener);
        if (listener == nullptr) {
            // Weak reference went out of scope