diff --git a/src/external/android-jni-wrap/wrap/android.content.cpp b/src/external/android-jni-wrap/wrap/android.content.cpp index 7c195016b..90726786b 100644 --- a/src/external/android-jni-wrap/wrap/android.content.cpp +++ b/src/external/android-jni-wrap/wrap/android.content.cpp @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -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(); } diff --git a/src/external/android-jni-wrap/wrap/android.content.h b/src/external/android-jni-wrap/wrap/android.content.h index 9a4853079..be8845c50 100644 --- a/src/external/android-jni-wrap/wrap/android.content.h +++ b/src/external/android-jni-wrap/wrap/android.content.h @@ -8,10 +8,6 @@ #include 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 diff --git a/src/external/android-jni-wrap/wrap/android.content.impl.h b/src/external/android-jni-wrap/wrap/android.content.impl.h index e44badc7a..642593895 100644 --- a/src/external/android-jni-wrap/wrap/android.content.impl.h +++ b/src/external/android-jni-wrap/wrap/android.content.impl.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik // Inline implementations: do not include on its own! @@ -54,6 +54,12 @@ inline java::lang::ClassLoader Context::getClassLoader() { object().call(Meta::data().getClassLoader)); } +inline java::io::File Context::getExternalFilesDir(std::string const &type) { + assert(!isNull()); + return java::io::File( + object().call(Meta::data().getExternalFilesDir, type)); +} + inline void Context::startActivity(Intent const &intent) { assert(!isNull()); return object().call(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(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(Meta::data().createDisplayContext, display.object())); -} - -inline jni::Object Context::getSystemService(std::string const &name) { - assert(!isNull()); - return object().call(Meta::data().getSystemService, name); -} - -inline java::io::File Context::getExternalFilesDir(std::string const &type) { - assert(!isNull()); - return java::io::File(object().call(Meta::data().getExternalFilesDir, type)); + return Context(object().call(Meta::data().createDisplayContext, + display.object())); } inline net::Uri_Builder ContentUris::appendId(net::Uri_Builder &uri_Builder, diff --git a/src/external/android-jni-wrap/wrap/android.content.pm.cpp b/src/external/android-jni-wrap/wrap/android.content.pm.cpp index 3a4fe0ddd..f527dd9fc 100644 --- a/src/external/android-jni-wrap/wrap/android.content.pm.cpp +++ b/src/external/android-jni-wrap/wrap/android.content.pm.cpp @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -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()) { diff --git a/src/external/android-jni-wrap/wrap/android.content.pm.h b/src/external/android-jni-wrap/wrap/android.content.pm.h index 5cb9c7434..3ecf68ab1 100644 --- a/src/external/android-jni-wrap/wrap/android.content.pm.h +++ b/src/external/android-jni-wrap/wrap/android.content.pm.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -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; /*! * 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"; } diff --git a/src/external/android-jni-wrap/wrap/android.content.pm.impl.h b/src/external/android-jni-wrap/wrap/android.content.pm.impl.h index 84b405073..a9b44cce7 100644 --- a/src/external/android-jni-wrap/wrap/android.content.pm.impl.h +++ b/src/external/android-jni-wrap/wrap/android.content.pm.impl.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik // 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()); diff --git a/src/external/android-jni-wrap/wrap/android.provider.cpp b/src/external/android-jni-wrap/wrap/android.provider.cpp index 15bf64222..0a247682b 100644 --- a/src/external/android-jni-wrap/wrap/android.provider.cpp +++ b/src/external/android-jni-wrap/wrap/android.provider.cpp @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -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 diff --git a/src/external/android-jni-wrap/wrap/android.provider.h b/src/external/android-jni-wrap/wrap/android.provider.h index 777188fc5..aa8e6933e 100644 --- a/src/external/android-jni-wrap/wrap/android.provider.h +++ b/src/external/android-jni-wrap/wrap/android.provider.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -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 diff --git a/src/external/android-jni-wrap/wrap/android.provider.impl.h b/src/external/android-jni-wrap/wrap/android.provider.impl.h index b1318817f..e676cdfee 100644 --- a/src/external/android-jni-wrap/wrap/android.provider.impl.h +++ b/src/external/android-jni-wrap/wrap/android.provider.impl.h @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik // 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(Meta::data().canDrawOverlays, context.object()); } + } // namespace android::provider } // namespace wrap