Monado OpenXR Runtime
android_load_class.hpp
Go to the documentation of this file.
1// Copyright 2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Function for loading Java code from a package.
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#include "wrap/android.app.h"
15
16#ifdef XRT_OS_ANDROID
17
18//! C++-only functionality in the Android auxiliary library
19namespace xrt::auxiliary::android {
20
21using wrap::android::content::pm::ApplicationInfo;
22
23/*!
24 * @note Starting from Android 11, NameNotFoundException exception is thrown if application doesn't
25 * specify either <queries> or "android.permission.QUERY_ALL_PACKAGES".
26 * See https://developer.android.com/training/package-visibility for detail.
27 *
28 * We work around this by querying first for org.khronos.openxr.OpenXRRuntimeService, for which a query entry is
29 * added by the Loader manifest.
30 */
31ApplicationInfo
32getAppInfo(std::string const &packageName, jobject application_context);
33
34/*!
35 * @note Starting from Android 11, NameNotFoundException exception is thrown if application doesn't
36 * specify either <queries> or "android.permission.QUERY_ALL_PACKAGES".
37 * See https://developer.android.com/training/package-visibility for detail.
38 */
39wrap::java::lang::Class
40loadClassFromPackage(ApplicationInfo applicationInfo, jobject application_context, const char *clazz_name);
41
42/*!
43 * Loading class from given apk path.
44 *
45 * @param application_context Context.
46 * @param apk_path Path to apk.
47 * @param clazz_name Name of class to be loaded.
48 * @return Class object.
49 */
50wrap::java::lang::Class
51loadClassFromApk(jobject application_context, const char *apk_path, const char *clazz_name);
52
53/*!
54 * Loading class from runtime apk.
55 *
56 * @param application_context Context.
57 * @param clazz_name Name of class to be loaded.
58 * @return Class object.
59 */
60wrap::java::lang::Class
61loadClassFromRuntimeApk(jobject application_context, const char *clazz_name);
62
63} // namespace xrt::auxiliary::android
64
65#endif // XRT_OS_ANDROID
Auto detect OS and certain features.