···11- Move `xrt_instance_info` members to nested `xrt_application_info` struct, and add a parallel `xrt_platform_info`.
22- Add `xrt/xrt_android.h` header.
33+- Add `xrt_instance_android` interface, optional aspect of `xrt_instance` when building on Android.
+147
src/xrt/include/xrt/xrt_android.h
···4747 enum xrt_android_lifecycle_event event,
4848 void *userdata);
49495050+#ifdef XRT_OS_ANDROID
5151+5252+/*!
5353+ * @interface xrt_instance_android
5454+ *
5555+ * This is the interface to the Android-specific "aspect" of @ref xrt_instance.
5656+ *
5757+ * It is expected that your implementation of this interface will be nested in your
5858+ * implementation of @ref xrt_instance. It does not have a separate create or
5959+ * destroy function as it is an (optional) aspect of the instance.
6060+ */
6161+struct xrt_instance_android
6262+{
6363+6464+ /*!
6565+ * @name Interface Methods
6666+ *
6767+ * All Android-based implementations of the xrt_instance interface must additionally populate all these function
6868+ * pointers with their implementation methods. To use this interface, see the helper functions.
6969+ * @{
7070+ */
7171+ /*!
7272+ * Retrieve the stored Java VM instance pointer.
7373+ *
7474+ * @note Code consuming this interface should use xrt_instance_android_get_vm()
7575+ *
7676+ * @param xinst_android Pointer to self
7777+ *
7878+ * @return The VM pointer.
7979+ */
8080+ struct _JavaVM *(*get_vm)(const struct xrt_instance_android *xinst_android);
8181+8282+ /*!
8383+ * Retrieve the stored activity android.content.Context jobject.
8484+ *
8585+ * For usage, cast the return value to jobject - a typedef whose definition
8686+ * differs between C (a void *) and C++ (a pointer to an empty class)
8787+ *
8888+ * @note Code consuming this interface should use xrt_instance_android_get_context()
8989+ *
9090+ * @param xinst_android Pointer to self
9191+ *
9292+ * @return The activity context.
9393+ */
9494+ void *(*get_context)(const struct xrt_instance_android *xinst_android);
9595+9696+ /*!
9797+ * Register a activity lifecycle event callback.
9898+ *
9999+ * @note Code consuming this interface should use xrt_instance_android_register_activity_lifecycle_callback()
100100+ *
101101+ * @param xinst_android Pointer to self
102102+ * @param callback Function pointer for callback
103103+ * @param event_mask bitwise-OR of one or more values from @ref xrt_android_lifecycle_event
104104+ * @param userdata An opaque pointer for use by the callback. Whatever you pass here will be passed to the
105105+ * callback when invoked.
106106+ *
107107+ * @return XRT_SUCCESS on success, other error code on error.
108108+ */
109109+ xrt_result_t (*register_activity_lifecycle_callback)(struct xrt_instance_android *xinst_android,
110110+ xrt_android_lifecycle_event_handler_t callback,
111111+ enum xrt_android_lifecycle_event event_mask,
112112+ void *userdata);
113113+114114+ /*!
115115+ * Remove a activity lifecycle event callback that matches the supplied parameters.
116116+ *
117117+ * @note Code consuming this interface should use xrt_instance_android_remove_activity_lifecycle_callback()
118118+ *
119119+ * @param xinst_android Pointer to self
120120+ * @param callback Function pointer for callback
121121+ * @param event_mask bitwise-OR of one or more values from @ref xrt_android_lifecycle_event
122122+ * @param userdata An opaque pointer for use by the callback. Whatever you pass here will be passed to the
123123+ * callback when invoked.
124124+ *
125125+ * @return XRT_SUCCESS on success (at least one callback was removed), @ref XRT_ERROR_ANDROID on error.
126126+ */
127127+ xrt_result_t (*remove_activity_lifecycle_callback)(struct xrt_instance_android *xinst_android,
128128+ xrt_android_lifecycle_event_handler_t callback,
129129+ enum xrt_android_lifecycle_event event_mask,
130130+ void *userdata);
131131+132132+ /*!
133133+ * @}
134134+ */
135135+};
136136+137137+/*!
138138+ * @copydoc xrt_instance_android::get_vm
139139+ *
140140+ * Helper for calling through the function pointer.
141141+ *
142142+ * @public @memberof xrt_instance_android
143143+ */
144144+static inline struct _JavaVM *
145145+xrt_instance_android_get_vm(struct xrt_instance_android *xinst_android)
146146+{
147147+ return xinst_android->get_vm(xinst_android);
148148+}
149149+150150+/*!
151151+ * @copydoc xrt_instance_android::get_context
152152+ *
153153+ * Helper for calling through the function pointer.
154154+ *
155155+ * @public @memberof xrt_instance_android
156156+ */
157157+static inline void *
158158+xrt_instance_android_get_context(struct xrt_instance_android *xinst_android)
159159+{
160160+ return xinst_android->get_context(xinst_android);
161161+}
162162+163163+/*!
164164+ * @copydoc xrt_instance_android::register_activity_lifecycle_callback
165165+ *
166166+ * Helper for calling through the function pointer.
167167+ *
168168+ * @public @memberof xrt_instance_android
169169+ */
170170+static inline xrt_result_t
171171+xrt_instance_android_register_activity_lifecycle_callback(struct xrt_instance_android *xinst_android,
172172+ xrt_android_lifecycle_event_handler_t callback,
173173+ enum xrt_android_lifecycle_event event_mask,
174174+ void *userdata)
175175+{
176176+ return xinst_android->register_activity_lifecycle_callback(xinst_android, callback, event_mask, userdata);
177177+}
178178+179179+/*!
180180+ * @copydoc xrt_instance_android::remove_activity_lifecycle_callback
181181+ *
182182+ * Helper for calling through the function pointer.
183183+ *
184184+ * @public @memberof xrt_instance_android
185185+ */
186186+static inline xrt_result_t
187187+xrt_instance_android_remove_activity_lifecycle_callback(struct xrt_instance_android *xinst_android,
188188+ xrt_android_lifecycle_event_handler_t callback,
189189+ enum xrt_android_lifecycle_event event_mask,
190190+ void *userdata)
191191+{
192192+ return xinst_android->remove_activity_lifecycle_callback(xinst_android, callback, event_mask, userdata);
193193+}
194194+195195+#endif // XRT_OS_ANDROID
196196+50197#ifdef __cplusplus
51198}
52199#endif
+9-1
src/xrt/include/xrt/xrt_instance.h
···22222323struct xrt_prober;
2424struct xrt_device;
2525+struct xrt_instance_android;
2526struct xrt_space_overseer;
2627struct xrt_system;
2728struct xrt_system_devices;
···114115 /*!
115116 * @name Interface Methods
116117 *
117117- * All implementations of the xrt_instance implementation must
118118+ * All implementations of the xrt_instance interface must
118119 * populate all these function pointers with their implementation
119120 * methods. To use this interface, see the helper functions.
120121 * @{
···178179 struct xrt_instance_info instance_info;
179180180181 uint64_t startup_timestamp;
182182+183183+ /*!
184184+ * An "aspect" of the xrt_instance interface, used only on Android.
185185+ *
186186+ * @see xrt_instance_android
187187+ */
188188+ struct xrt_instance_android *android_instance;
181189};
182190183191/*!