The open source OpenXR runtime

ipc: Improve android

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2308>

+4 -4
+4 -4
src/xrt/ipc/android/ipc_client_android.cpp
··· 25 25 26 26 struct ipc_client_android 27 27 { 28 - ipc_client_android(jobject act) : activity(act) {} 28 + ipc_client_android(struct _JavaVM *vm_, jobject act) : vm(vm_), activity(act) {} 29 29 ~ipc_client_android(); 30 + struct _JavaVM *vm; 30 31 31 32 Activity activity{}; 32 33 Client client{nullptr}; ··· 61 62 62 63 // Teach the wrapper our class before we start to use it. 63 64 Client::staticInitClass((jclass)clazz.object().getHandle()); 64 - std::unique_ptr<ipc_client_android> ret = std::make_unique<ipc_client_android>((jobject)activity); 65 + std::unique_ptr<ipc_client_android> ret = std::make_unique<ipc_client_android>(vm, (jobject)activity); 65 66 66 67 ret->client = Client::construct(ret.get()); 67 68 ··· 79 80 try { 80 81 // Trick to avoid deadlock on main thread: only applicable to NativeActivity with app-glue. 81 82 // blockingConnect will block until binder is ready, the app-glue code will deadlock without this. 82 - JavaVM *vm = nullptr; 83 - jni::env()->GetJavaVM(&vm); 83 + JavaVM *vm = ica->vm; 84 84 android_looper_poll_until_activity_resumed(vm, ica->activity.object().getHandle()); 85 85 int fd = ica->client.blockingConnect(ica->activity, XRT_ANDROID_PACKAGE); 86 86 return fd;