2020-09-08 19:31:50 +00:00
|
|
|
// Copyright 2020, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Function for loading Java code from a package.
|
|
|
|
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
* @ingroup aux_android
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <xrt/xrt_config_os.h>
|
|
|
|
|
2020-09-25 17:59:08 +00:00
|
|
|
#include "wrap/android.app.h"
|
|
|
|
|
2020-09-08 19:31:50 +00:00
|
|
|
#ifdef XRT_OS_ANDROID
|
|
|
|
|
2021-04-30 22:23:59 +00:00
|
|
|
//! C++-only functionality in the Android auxiliary library
|
|
|
|
namespace xrt::auxiliary::android {
|
|
|
|
|
2020-09-25 17:59:08 +00:00
|
|
|
using wrap::android::content::pm::ApplicationInfo;
|
2020-09-08 19:31:50 +00:00
|
|
|
|
2022-08-30 15:41:41 +00:00
|
|
|
/*!
|
|
|
|
* @note Starting from Android 11, NameNotFoundException exception is thrown if application doesn't
|
|
|
|
* specify either <queries> or "android.permission.QUERY_ALL_PACKAGES".
|
|
|
|
* See https://developer.android.com/training/package-visibility for detail.
|
2023-04-24 19:59:21 +00:00
|
|
|
*
|
|
|
|
* We work around this by querying first for org.khronos.openxr.OpenXRRuntimeService, for which a query entry is
|
|
|
|
* added by the Loader manifest.
|
2022-08-30 15:41:41 +00:00
|
|
|
*/
|
2020-09-25 17:59:08 +00:00
|
|
|
ApplicationInfo
|
|
|
|
getAppInfo(std::string const &packageName, jobject application_context);
|
2020-09-08 19:31:50 +00:00
|
|
|
|
2022-08-30 15:41:41 +00:00
|
|
|
/*!
|
|
|
|
* @note Starting from Android 11, NameNotFoundException exception is thrown if application doesn't
|
|
|
|
* specify either <queries> or "android.permission.QUERY_ALL_PACKAGES".
|
|
|
|
* See https://developer.android.com/training/package-visibility for detail.
|
|
|
|
*/
|
2020-09-25 17:59:08 +00:00
|
|
|
wrap::java::lang::Class
|
2021-01-14 14:13:48 +00:00
|
|
|
loadClassFromPackage(ApplicationInfo applicationInfo, jobject application_context, const char *clazz_name);
|
2020-09-08 19:31:50 +00:00
|
|
|
|
2022-08-30 15:41:41 +00:00
|
|
|
/*!
|
|
|
|
* Loading class from given apk path.
|
|
|
|
*
|
|
|
|
* @param application_context Context.
|
|
|
|
* @param apk_path Path to apk.
|
|
|
|
* @param clazz_name Name of class to be loaded.
|
|
|
|
* @return Class object.
|
|
|
|
*/
|
|
|
|
wrap::java::lang::Class
|
|
|
|
loadClassFromApk(jobject application_context, const char *apk_path, const char *clazz_name);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Loading class from runtime apk.
|
|
|
|
*
|
|
|
|
* @param application_context Context.
|
|
|
|
* @param clazz_name Name of class to be loaded.
|
|
|
|
* @return Class object.
|
|
|
|
*/
|
|
|
|
wrap::java::lang::Class
|
|
|
|
loadClassFromRuntimeApk(jobject application_context, const char *clazz_name);
|
|
|
|
|
2021-04-30 22:23:59 +00:00
|
|
|
} // namespace xrt::auxiliary::android
|
|
|
|
|
2020-09-08 19:31:50 +00:00
|
|
|
#endif // XRT_OS_ANDROID
|