From 5e70aa5597c8c6c337ff9ff6bfb11469e05fa890 Mon Sep 17 00:00:00 2001 From: chaviw Date: Fri, 1 Apr 2022 10:39:25 -0500 Subject: [PATCH] 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 --- core/jni/android_window_WindowInfosListener.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jni/android_window_WindowInfosListener.cpp b/core/jni/android_window_WindowInfosListener.cpp index aae2549df429..f2cbe8abae8b 100644 --- a/core/jni/android_window_WindowInfosListener.cpp +++ b/core/jni/android_window_WindowInfosListener.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #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