The open source OpenXR runtime
at prediction-2 82 lines 1.9 kB view raw
1// Copyright 2020, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3/*! 4 * @file 5 * @brief Functions for Android-specific global state. 6 * @author Rylie Pavlik <rylie.pavlik@collabora.com> 7 * @ingroup aux_android 8 */ 9 10#pragma once 11 12#include <xrt/xrt_config_os.h> 13 14#ifdef XRT_OS_ANDROID 15 16#ifdef __cplusplus 17extern "C" { 18#endif 19 20struct _JNIEnv; 21struct _JavaVM; 22struct _ANativeWindow; 23 24/*! 25 * Store the Java VM pointer and the android.app.Activity jobject. 26 */ 27void 28android_globals_store_vm_and_activity(struct _JavaVM *vm, void *activity); 29 30 31/*! 32 * Store the Java VM pointer and the android.content.Context jobject. 33 */ 34void 35android_globals_store_vm_and_context(struct _JavaVM *vm, void *context); 36 37 38/*! 39 * Is the provided jobject an instance of android.app.Activity? 40 */ 41bool 42android_globals_is_instance_of_activity(struct _JavaVM *vm, void *obj); 43 44/*! 45 * Retrieve the Java VM pointer previously stored, if any. 46 */ 47struct _JavaVM * 48android_globals_get_vm(void); 49 50/*! 51 * Retrieve the android.app.Activity jobject previously stored, if any. 52 * 53 * For usage, cast the return value to jobject - a typedef whose definition 54 * differs between C (a void *) and C++ (a pointer to an empty class) 55 */ 56void * 57android_globals_get_activity(void); 58 59/*! 60 * Retrieve the android.content.Context jobject previously stored, if any. 61 * 62 * Since android.app.Activity is a sub-class of android.content.Context, the 63 * activity jobject will be returned if it has been set but the context has not. 64 * 65 * For usage, cast the return value to jobject - a typedef whose definition 66 * differs between C (a void *) and C++ (a pointer to an empty class) 67 */ 68void * 69android_globals_get_context(void); 70 71 72void 73android_globals_store_window(struct _ANativeWindow *window); 74 75struct _ANativeWindow * 76android_globals_get_window(void); 77 78#ifdef __cplusplus 79} 80#endif 81 82#endif // XRT_OS_ANDROID