diff options
| author | 2022-04-18 09:00:24 -0500 | |
|---|---|---|
| committer | 2022-04-18 09:27:24 -0500 | |
| commit | db07b07b2b198f0bdc7bfb817b35410970b65f3c (patch) | |
| tree | a6d310bb6462abc9d425697ffcecdab926f338f7 | |
| parent | e360c271c6f02693d189774f5967c237896d2d7b (diff) | |
Construct Region object with nativeObject
The default ctor for the Java Region object creates a native SkRegion
object. Hoewver, in the JNI code we overwrite the native pointer so the
native object created from the default ctor never gets cleaned up.
Instead, use the ctor that accepts a native ptr so we create the Region
object with native info populated.
Test: Builds
Fixes: 229537097
Change-Id: I89e4b8ec985c538e7337c0e80415d3b6474da78e
| -rw-r--r-- | core/jni/android_hardware_input_InputWindowHandle.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/core/jni/android_hardware_input_InputWindowHandle.cpp b/core/jni/android_hardware_input_InputWindowHandle.cpp index 973ed29d8e72..241320f31748 100644 --- a/core/jni/android_hardware_input_InputWindowHandle.cpp +++ b/core/jni/android_hardware_input_InputWindowHandle.cpp @@ -79,7 +79,6 @@ static struct { static struct { jclass clazz; jmethodID ctor; - jfieldID nativeRegion; } gRegionClassInfo; static Mutex gHandleMutex; @@ -290,10 +289,8 @@ jobject android_view_InputWindowHandle_fromWindowInfo(JNIEnv* env, gui::WindowIn region->op({r.left, r.top, r.right, r.bottom}, SkRegion::kUnion_Op); } ScopedLocalRef<jobject> regionObj(env, - env->NewObject(gRegionClassInfo.clazz, - gRegionClassInfo.ctor)); - env->SetLongField(regionObj.get(), gRegionClassInfo.nativeRegion, - reinterpret_cast<jlong>(region)); + env->NewObject(gRegionClassInfo.clazz, gRegionClassInfo.ctor, + reinterpret_cast<jlong>(region))); env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.touchableRegion, regionObj.get()); @@ -453,8 +450,7 @@ int register_android_view_InputWindowHandle(JNIEnv* env) { jclass regionClazz; FIND_CLASS(regionClazz, "android/graphics/Region"); gRegionClassInfo.clazz = MakeGlobalRefOrDie(env, regionClazz); - GET_METHOD_ID(gRegionClassInfo.ctor, gRegionClassInfo.clazz, "<init>", "()V"); - GET_FIELD_ID(gRegionClassInfo.nativeRegion, gRegionClassInfo.clazz, "mNativeRegion", "J"); + GET_METHOD_ID(gRegionClassInfo.ctor, gRegionClassInfo.clazz, "<init>", "(J)V"); return 0; } |