mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
android-jni-wrap: Update to add more things
This commit is contained in:
parent
aa052046a8
commit
f57bc4a849
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
|
@ -18,19 +18,20 @@ Context::Meta::Meta(bool deferDrop)
|
|||
"getApplicationContext", "()Landroid/content/Context;")),
|
||||
getClassLoader(
|
||||
classRef().getMethod("getClassLoader", "()Ljava/lang/ClassLoader;")),
|
||||
getExternalFilesDir(classRef().getMethod(
|
||||
"getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;")),
|
||||
startActivity(
|
||||
classRef().getMethod("startActivity", "(Landroid/content/Intent;)V")),
|
||||
startActivity1(classRef().getMethod(
|
||||
"startActivity", "(Landroid/content/Intent;Landroid/os/Bundle;)V")),
|
||||
getSystemService(classRef().getMethod(
|
||||
"getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;")),
|
||||
createPackageContext(classRef().getMethod(
|
||||
"createPackageContext",
|
||||
"(Ljava/lang/String;I)Landroid/content/Context;")),
|
||||
createDisplayContext(classRef().getMethod(
|
||||
"createDisplayContext", "(Landroid/view/Display;)Landroid/content/Context;")),
|
||||
getSystemService(classRef().getMethod(
|
||||
"getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;")),
|
||||
getExternalFilesDir(classRef().getMethod(
|
||||
"getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;")) {
|
||||
"createDisplayContext",
|
||||
"(Landroid/view/Display;)Landroid/content/Context;")) {
|
||||
if (!deferDrop) {
|
||||
MetaBaseDroppable::dropClassRef();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
#include <string>
|
||||
|
||||
namespace wrap {
|
||||
namespace java::io {
|
||||
class File;
|
||||
} // namespace java::io
|
||||
|
||||
namespace android::content {
|
||||
class ComponentName;
|
||||
class ContentResolver;
|
||||
|
@ -32,13 +28,17 @@ class Uri;
|
|||
class Uri_Builder;
|
||||
} // namespace android::net
|
||||
|
||||
namespace android::os {
|
||||
class Bundle;
|
||||
} // namespace android::os
|
||||
|
||||
namespace android::view {
|
||||
class Display;
|
||||
} // namespace android::view
|
||||
|
||||
namespace android::os {
|
||||
class Bundle;
|
||||
} // namespace android::os
|
||||
namespace java::io {
|
||||
class File;
|
||||
} // namespace java::io
|
||||
|
||||
namespace java::lang {
|
||||
class Class;
|
||||
|
@ -125,6 +125,17 @@ class Context : public ObjectWrapperBase {
|
|||
*/
|
||||
java::lang::ClassLoader getClassLoader();
|
||||
|
||||
/*!
|
||||
* Wrapper for the getExternalFilesDir method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public abstract java.io.File getExternalFilesDir(java.lang.String);`
|
||||
*
|
||||
* JNI signature: (Ljava/lang/String;)Ljava/io/File;
|
||||
*
|
||||
*/
|
||||
java::io::File getExternalFilesDir(std::string const &type);
|
||||
|
||||
/*!
|
||||
* Wrapper for the startActivity method
|
||||
*
|
||||
|
@ -148,6 +159,17 @@ class Context : public ObjectWrapperBase {
|
|||
*/
|
||||
void startActivity(Intent const &intent, os::Bundle const &bundle);
|
||||
|
||||
/*!
|
||||
* Wrapper for the getSystemService method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public abstract java.lang.Object getSystemService(java.lang.String);`
|
||||
*
|
||||
* JNI signature: (Ljava/lang/String;)Ljava/lang/Object;
|
||||
*
|
||||
*/
|
||||
jni::Object getSystemService(std::string const &name);
|
||||
|
||||
/*!
|
||||
* Wrapper for the createPackageContext method
|
||||
*
|
||||
|
@ -165,34 +187,13 @@ class Context : public ObjectWrapperBase {
|
|||
* Wrapper for the createDisplayContext method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public abstract Context createDisplayContext(android.view.Display display)`
|
||||
* `public abstract android.content.Context
|
||||
* createDisplayContext(android.view.Display);`
|
||||
*
|
||||
* JNI signature: (Landroid/view/Display;)Landroid/content/Context;
|
||||
*
|
||||
*/
|
||||
Context createDisplayContext(wrap::android::view::Display const &display);
|
||||
|
||||
/*!
|
||||
* Wrapper for the getSystemService method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public abstract java.lang.Object getSystemService(java.lang.String);`
|
||||
*
|
||||
* JNI signature: (Ljava/lang/String;)Ljava/lang/Object;
|
||||
*
|
||||
*/
|
||||
jni::Object getSystemService(std::string const &name);
|
||||
|
||||
/*!
|
||||
* Wrapper for the getExternalFilesDir method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public abstract java.io.File getExternalFilesDir(java.lang.String);`
|
||||
*
|
||||
* JNI signature: (Ljava/lang/String;)Ljava/io/File;
|
||||
*
|
||||
*/
|
||||
java::io::File getExternalFilesDir(std::string const &type);
|
||||
Context createDisplayContext(view::Display const &display);
|
||||
|
||||
enum {
|
||||
CONTEXT_INCLUDE_CODE = 1,
|
||||
|
@ -209,12 +210,12 @@ class Context : public ObjectWrapperBase {
|
|||
jni::method_t getContentResolver;
|
||||
jni::method_t getApplicationContext;
|
||||
jni::method_t getClassLoader;
|
||||
jni::method_t getExternalFilesDir;
|
||||
jni::method_t startActivity;
|
||||
jni::method_t startActivity1;
|
||||
jni::method_t getSystemService;
|
||||
jni::method_t createPackageContext;
|
||||
jni::method_t createDisplayContext;
|
||||
jni::method_t getSystemService;
|
||||
jni::method_t getExternalFilesDir;
|
||||
|
||||
/*!
|
||||
* Singleton accessor
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Inline implementations: do not include on its own!
|
||||
|
@ -54,6 +54,12 @@ inline java::lang::ClassLoader Context::getClassLoader() {
|
|||
object().call<jni::Object>(Meta::data().getClassLoader));
|
||||
}
|
||||
|
||||
inline java::io::File Context::getExternalFilesDir(std::string const &type) {
|
||||
assert(!isNull());
|
||||
return java::io::File(
|
||||
object().call<jni::Object>(Meta::data().getExternalFilesDir, type));
|
||||
}
|
||||
|
||||
inline void Context::startActivity(Intent const &intent) {
|
||||
assert(!isNull());
|
||||
return object().call<void>(Meta::data().startActivity, intent.object());
|
||||
|
@ -66,6 +72,11 @@ inline void Context::startActivity(Intent const &intent,
|
|||
bundle.object());
|
||||
}
|
||||
|
||||
inline jni::Object Context::getSystemService(std::string const &name) {
|
||||
assert(!isNull());
|
||||
return object().call<jni::Object>(Meta::data().getSystemService, name);
|
||||
}
|
||||
|
||||
inline Context Context::createPackageContext(std::string const &packageName,
|
||||
int32_t flags) {
|
||||
assert(!isNull());
|
||||
|
@ -73,19 +84,10 @@ inline Context Context::createPackageContext(std::string const &packageName,
|
|||
packageName, flags));
|
||||
}
|
||||
|
||||
inline Context Context::createDisplayContext(const wrap::android::view::Display &display) {
|
||||
inline Context Context::createDisplayContext(view::Display const &display) {
|
||||
assert(!isNull());
|
||||
return Context(object().call<jni::Object>(Meta::data().createDisplayContext, display.object()));
|
||||
}
|
||||
|
||||
inline jni::Object Context::getSystemService(std::string const &name) {
|
||||
assert(!isNull());
|
||||
return object().call<jni::Object>(Meta::data().getSystemService, name);
|
||||
}
|
||||
|
||||
inline java::io::File Context::getExternalFilesDir(std::string const &type) {
|
||||
assert(!isNull());
|
||||
return java::io::File(object().call<jni::Object>(Meta::data().getExternalFilesDir, type));
|
||||
return Context(object().call<jni::Object>(Meta::data().createDisplayContext,
|
||||
display.object()));
|
||||
}
|
||||
|
||||
inline net::Uri_Builder ContentUris::appendId(net::Uri_Builder &uri_Builder,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
|
@ -12,7 +12,9 @@ PackageItemInfo::Meta::Meta()
|
|||
packageName(classRef(), "packageName") {
|
||||
MetaBaseDroppable::dropClassRef();
|
||||
}
|
||||
ComponentInfo::Meta::Meta() : MetaBaseDroppable(ComponentInfo::getTypeName()) {
|
||||
ComponentInfo::Meta::Meta()
|
||||
: MetaBaseDroppable(ComponentInfo::getTypeName()),
|
||||
applicationInfo(classRef(), "applicationInfo") {
|
||||
MetaBaseDroppable::dropClassRef();
|
||||
}
|
||||
ServiceInfo::Meta::Meta() : MetaBaseDroppable(ServiceInfo::getTypeName()) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
|
@ -105,10 +105,22 @@ class ComponentInfo : public PackageItemInfo {
|
|||
return "android/content/pm/ComponentInfo";
|
||||
}
|
||||
|
||||
/*!
|
||||
* Getter for the applicationInfo field value
|
||||
*
|
||||
* Java prototype:
|
||||
* `public android.content.pm.ApplicationInfo applicationInfo;`
|
||||
*
|
||||
* JNI signature: Landroid/content/pm/ApplicationInfo;
|
||||
*
|
||||
*/
|
||||
ApplicationInfo getApplicationInfo() const;
|
||||
|
||||
/*!
|
||||
* Class metadata
|
||||
*/
|
||||
struct Meta : public MetaBaseDroppable {
|
||||
impl::WrappedFieldId<ApplicationInfo> applicationInfo;
|
||||
|
||||
/*!
|
||||
* Singleton accessor
|
||||
|
@ -126,9 +138,9 @@ class ComponentInfo : public PackageItemInfo {
|
|||
/*!
|
||||
* Wrapper for android.content.pm.ServiceInfo objects.
|
||||
*/
|
||||
class ServiceInfo : public PackageItemInfo {
|
||||
class ServiceInfo : public ComponentInfo {
|
||||
public:
|
||||
using PackageItemInfo::PackageItemInfo;
|
||||
using ComponentInfo::ComponentInfo;
|
||||
static constexpr const char *getTypeName() noexcept {
|
||||
return "android/content/pm/ServiceInfo";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Inline implementations: do not include on its own!
|
||||
|
@ -26,6 +26,11 @@ inline std::string PackageItemInfo::getPackageName() const {
|
|||
return get(Meta::data().packageName, object());
|
||||
}
|
||||
|
||||
inline ApplicationInfo ComponentInfo::getApplicationInfo() const {
|
||||
assert(!isNull());
|
||||
return get(Meta::data().applicationInfo, object());
|
||||
}
|
||||
|
||||
inline std::string ApplicationInfo::getNativeLibraryDir() const {
|
||||
assert(!isNull());
|
||||
return get(Meta::data().nativeLibraryDir, object());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
|
@ -10,6 +10,6 @@ Settings::Meta::Meta()
|
|||
: MetaBase(Settings::getTypeName()),
|
||||
ACTION_VR_LISTENER_SETTINGS(classRef(), "ACTION_VR_LISTENER_SETTINGS"),
|
||||
canDrawOverlays(classRef().getStaticMethod(
|
||||
"canDrawOverlays", "(Landroid/content/Context;)Z")) {}
|
||||
"canDrawOverlays", "(Landroid/content/Context;)Z")) {}
|
||||
} // namespace android::provider
|
||||
} // namespace wrap
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
|
||||
|
@ -9,9 +9,12 @@
|
|||
|
||||
namespace wrap {
|
||||
namespace android::content {
|
||||
class Context;
|
||||
class Context;
|
||||
} // namespace android::content
|
||||
|
||||
} // namespace wrap
|
||||
|
||||
namespace wrap {
|
||||
namespace android::provider {
|
||||
/*!
|
||||
* Wrapper for android.provider.Settings objects.
|
||||
|
@ -38,14 +41,12 @@ class Settings : public ObjectWrapperBase {
|
|||
* Wrapper for the canDrawOverlays static method
|
||||
*
|
||||
* Java prototype:
|
||||
* `public static final boolean
|
||||
* canDrawOverlays(android.content.Context);`
|
||||
* `public static boolean canDrawOverlays(android.content.Context);`
|
||||
*
|
||||
* JNI signature:
|
||||
* (Landroid/content/Context;)Z
|
||||
* JNI signature: (Landroid/content/Context;)Z
|
||||
*
|
||||
*/
|
||||
static bool canDrawOverlays(content::Context const &context);
|
||||
static bool canDrawOverlays(const content::Context &context);
|
||||
|
||||
/*!
|
||||
* Class metadata
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021, Collabora, Ltd.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Inline implementations: do not include on its own!
|
||||
|
@ -17,5 +17,6 @@ inline bool Settings::canDrawOverlays(const content::Context &context) {
|
|||
return Meta::data().clazz().call<bool>(Meta::data().canDrawOverlays,
|
||||
context.object());
|
||||
}
|
||||
|
||||
} // namespace android::provider
|
||||
} // namespace wrap
|
||||
|
|
Loading…
Reference in a new issue