From fc78b5de867f3560de72ab1d38e4e3be9889c852 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 28 Oct 2020 11:33:30 -0500 Subject: [PATCH] a/android: Use android_custom_surface constructor/destructor --- src/xrt/auxiliary/android/android_custom_surface.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xrt/auxiliary/android/android_custom_surface.cpp b/src/xrt/auxiliary/android/android_custom_surface.cpp index b93846720..48c9903c6 100644 --- a/src/xrt/auxiliary/android/android_custom_surface.cpp +++ b/src/xrt/auxiliary/android/android_custom_surface.cpp @@ -19,7 +19,6 @@ #include -#include "jni.h" using wrap::android::app::Activity; using wrap::android::view::SurfaceHolder; @@ -27,6 +26,7 @@ using wrap::android::view::SurfaceHolder; struct android_custom_surface { + explicit android_custom_surface(jobject act); ~android_custom_surface(); Activity activity{}; jni::Class monadoViewClass{}; @@ -35,8 +35,12 @@ struct android_custom_surface jni::method_t markAsDiscardedMethod = nullptr; }; + +android_custom_surface::android_custom_surface(jobject act) : activity(act) {} + android_custom_surface::~android_custom_surface() { + // Tell Java that native code is done with this. if (!monadoView.isNull() && markAsDiscardedMethod != nullptr) { try { monadoView.call(markAsDiscardedMethod); @@ -58,9 +62,7 @@ android_custom_surface_async_start(struct _JavaVM *vm, void *activity) jni::method_t attachToActivity; try { std::unique_ptr ret = - std::make_unique(); - - ret->activity = Activity((jobject)activity); + std::make_unique((jobject)activity); auto info = getAppInfo(XRT_ANDROID_PACKAGE, (jobject)activity); if (info.isNull()) { U_LOG_E(