From cc6d483974c76d4ce29ad23407c12a5f70632d07 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 4 Feb 2019 15:41:12 -0800 Subject: [PATCH] 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 --- core/jni/android_view_SurfaceControl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index fad2fe0d38452..89bdf62b9ac34 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -178,12 +178,13 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { sp ctrl(reinterpret_cast(nativeObject)); + ctrl->release(); ctrl->decStrong((void *)nativeCreate); } static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) { sp ctrl(reinterpret_cast(nativeObject)); - ctrl->clear(); + ctrl->destroy(); ctrl->decStrong((void *)nativeCreate); }