From 78717c2c38628c6cacb37a19336cccfe93b013f3 Mon Sep 17 00:00:00 2001 From: Rylie Pavlik Date: Tue, 16 Mar 2021 17:26:32 -0500 Subject: [PATCH] xrt: Add xrt_android header with info about Android lifecycle callbacks Co-authored-By: Jarvis Huang Part-of: --- doc/changes/xrt/mr.1655.md | 1 + src/xrt/include/xrt/xrt_android.h | 52 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/xrt/include/xrt/xrt_android.h diff --git a/doc/changes/xrt/mr.1655.md b/doc/changes/xrt/mr.1655.md index e792dc31f..08c949fed 100644 --- a/doc/changes/xrt/mr.1655.md +++ b/doc/changes/xrt/mr.1655.md @@ -1 +1,2 @@ - Move `xrt_instance_info` members to nested `xrt_application_info` struct, and add a parallel `xrt_platform_info`. +- Add `xrt/xrt_android.h` header. diff --git a/src/xrt/include/xrt/xrt_android.h b/src/xrt/include/xrt/xrt_android.h new file mode 100644 index 000000000..acca7c7af --- /dev/null +++ b/src/xrt/include/xrt/xrt_android.h @@ -0,0 +1,52 @@ +// Copyright 2021-2024, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Header holding Android-specific details. + * @author Rylie Pavlik + * @ingroup xrt_iface + */ + +#pragma once + +#include "xrt/xrt_config_os.h" +#include "xrt/xrt_compiler.h" +#include "xrt/xrt_results.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct _JavaVM; +struct xrt_instance_android; +struct xrt_instance_info; + +/*! + * Distinguishes the possible Android lifecycle events from each other. + * + * Used as a bitmask when registering for callbacks. + */ +enum xrt_android_lifecycle_event +{ + XRT_ANDROID_LIVECYCLE_EVENT_ON_CREATE = 1 << 0, + XRT_ANDROID_LIVECYCLE_EVENT_ON_DESTROY = 1 << 1, + XRT_ANDROID_LIVECYCLE_EVENT_ON_PAUSE = 1 << 2, + XRT_ANDROID_LIVECYCLE_EVENT_ON_RESUME = 1 << 3, + XRT_ANDROID_LIVECYCLE_EVENT_ON_START = 1 << 4, + XRT_ANDROID_LIVECYCLE_EVENT_ON_STOP = 1 << 5, +}; + +/*! + * A callback type for a handler of Android lifecycle events. + * + * Return true to be removed from the callback list. + */ +typedef bool (*xrt_android_lifecycle_event_handler_t)(struct xrt_instance_android *xinst_android, + enum xrt_android_lifecycle_event event, + void *userdata); + +#ifdef __cplusplus +} +#endif