SurfaceControl: Fix release
Currently we call decStrong causing ~SurfaceControl to be invoked.
If mOwned=true this will cause a reparent to null which is not the
intended behavior of release. We call SurfaceControl#release before
decStrong to fix this. Also we have destroy call destroy to be less
confusing.
Bug: 123587983
Test: SurfaceControlTest
Change-Id: I86faa9d1eb850ac6437fc870b126a1473ee091e3
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index fad2fe0..89bdf62 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -178,12 +178,13 @@
static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
+ ctrl->release();
ctrl->decStrong((void *)nativeCreate);
}
static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
- ctrl->clear();
+ ctrl->destroy();
ctrl->decStrong((void *)nativeCreate);
}