From f35ce4ea9b0d3cd6b7429e92c01e1fe34ed6f581 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 30 Apr 2021 11:41:48 -0500 Subject: [PATCH] external: Update android-jni-wrap --- .../android-jni-wrap/wrap/android.app.cpp | 2 +- .../android-jni-wrap/wrap/android.app.h | 8 +- .../android-jni-wrap/wrap/android.app.impl.h | 4 +- .../android-jni-wrap/wrap/android.content.cpp | 21 ++- .../android-jni-wrap/wrap/android.content.h | 134 +++++++++++++++--- .../wrap/android.content.impl.h | 71 +++++++--- .../wrap/android.content.pm.cpp | 5 +- .../wrap/android.content.pm.h | 44 +++--- .../wrap/android.content.pm.impl.h | 24 ++-- .../wrap/android.database.cpp | 22 +++ .../android-jni-wrap/wrap/android.database.h | 125 ++++++++++++++++ .../wrap/android.database.impl.h | 48 +++++++ .../wrap/android.graphics.cpp | 2 +- .../android-jni-wrap/wrap/android.graphics.h | 5 +- .../wrap/android.graphics.impl.h | 4 +- .../android-jni-wrap/wrap/android.os.cpp | 2 +- .../android-jni-wrap/wrap/android.os.h | 10 +- .../android-jni-wrap/wrap/android.os.impl.h | 4 +- .../wrap/android.provider.cpp | 2 +- .../android-jni-wrap/wrap/android.provider.h | 5 +- .../wrap/android.provider.impl.h | 4 +- .../wrap/android.service.vr.cpp | 2 +- .../wrap/android.service.vr.h | 5 +- .../wrap/android.service.vr.impl.h | 4 +- .../android-jni-wrap/wrap/android.util.cpp | 2 +- .../android-jni-wrap/wrap/android.util.h | 5 +- .../android-jni-wrap/wrap/android.util.impl.h | 4 +- .../android-jni-wrap/wrap/android.view.cpp | 2 +- .../android-jni-wrap/wrap/android.view.h | 11 +- .../android-jni-wrap/wrap/android.view.impl.h | 6 +- .../android-jni-wrap/wrap/android.widget.cpp | 2 +- .../android-jni-wrap/wrap/android.widget.h | 9 +- .../wrap/android.widget.impl.h | 10 +- .../android-jni-wrap/wrap/dalvik.system.cpp | 15 -- .../android-jni-wrap/wrap/dalvik.system.h | 67 --------- .../wrap/dalvik.system.impl.h | 21 --- .../android-jni-wrap/wrap/java.lang.cpp | 5 +- .../android-jni-wrap/wrap/java.lang.h | 28 ++-- .../android-jni-wrap/wrap/java.lang.impl.h | 20 ++- .../android-jni-wrap/wrap/java.util.cpp | 2 +- .../android-jni-wrap/wrap/java.util.h | 5 +- .../android-jni-wrap/wrap/java.util.impl.h | 4 +- 42 files changed, 499 insertions(+), 276 deletions(-) create mode 100644 src/external/android-jni-wrap/wrap/android.database.cpp create mode 100644 src/external/android-jni-wrap/wrap/android.database.h create mode 100644 src/external/android-jni-wrap/wrap/android.database.impl.h delete mode 100644 src/external/android-jni-wrap/wrap/dalvik.system.cpp delete mode 100644 src/external/android-jni-wrap/wrap/dalvik.system.h delete mode 100644 src/external/android-jni-wrap/wrap/dalvik.system.impl.h diff --git a/src/external/android-jni-wrap/wrap/android.app.cpp b/src/external/android-jni-wrap/wrap/android.app.cpp index 66bb57a9e..36928ea24 100644 --- a/src/external/android-jni-wrap/wrap/android.app.cpp +++ b/src/external/android-jni-wrap/wrap/android.app.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.app.h b/src/external/android-jni-wrap/wrap/android.app.h index c57dabdbd..bb8698ea2 100644 --- a/src/external/android-jni-wrap/wrap/android.app.h +++ b/src/external/android-jni-wrap/wrap/android.app.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -34,7 +34,7 @@ class Service : public content::Context { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -42,6 +42,7 @@ class Service : public content::Context { Meta(); }; }; + /*! * Wrapper for android.app.Activity objects. */ @@ -87,7 +88,7 @@ class Activity : public content::Context { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -95,6 +96,7 @@ class Activity : public content::Context { Meta(); }; }; + } // namespace android::app } // namespace wrap #include "android.app.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.app.impl.h b/src/external/android-jni-wrap/wrap/android.app.impl.h index b5853e0f1..2319bd3dc 100644 --- a/src/external/android-jni-wrap/wrap/android.app.impl.h +++ b/src/external/android-jni-wrap/wrap/android.app.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -22,5 +23,6 @@ Activity::setVrModeEnabled(bool enabled, return object().call(Meta::data().setVrModeEnabled, enabled, requestedComponent.object()); } + } // namespace android::app } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.content.cpp b/src/external/android-jni-wrap/wrap/android.content.cpp index 7723d5f44..083bd5b27 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, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -12,6 +12,8 @@ Context::Meta::Meta(bool deferDrop) WINDOW_SERVICE(classRef(), "WINDOW_SERVICE"), getPackageManager(classRef().getMethod( "getPackageManager", "()Landroid/content/pm/PackageManager;")), + getContentResolver(classRef().getMethod( + "getContentResolver", "()Landroid/content/ContentResolver;")), getApplicationContext(classRef().getMethod( "getApplicationContext", "()Landroid/content/Context;")), getClassLoader( @@ -39,7 +41,6 @@ ComponentName::Meta::Meta() Intent::Meta::Meta() : MetaBase(Intent::getTypeName()), FLAG_ACTIVITY_NEW_TASK(classRef(), "FLAG_ACTIVITY_NEW_TASK"), - init(classRef().getMethod("", "()V")), init1(classRef().getMethod("", "(Landroid/content/Intent;)V")), init2(classRef().getMethod("", "(Ljava/lang/String;)V")), init3(classRef().getMethod("", @@ -51,5 +52,21 @@ Intent::Meta::Meta() "content/Context;Ljava/lang/Class;)V")), setFlags( classRef().getMethod("setFlags", "(I)Landroid/content/Intent;")) {} +ContentResolver::Meta::Meta() + : MetaBaseDroppable(ContentResolver::getTypeName()), + query(classRef().getMethod( + "query", + "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/" + "String;Ljava/lang/String;)Landroid/database/Cursor;")), + query1(classRef().getMethod( + "query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/" + "String;[Ljava/lang/String;Ljava/lang/String;Landroid/os/" + "CancellationSignal;)Landroid/database/Cursor;")), + query2(classRef().getMethod( + "query", + "(Landroid/net/Uri;[Ljava/lang/String;Landroid/os/Bundle;Landroid/os/" + "CancellationSignal;)Landroid/database/Cursor;")) { + MetaBaseDroppable::dropClassRef(); +} } // namespace android::content } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.content.h b/src/external/android-jni-wrap/wrap/android.content.h index 339bd2fa3..0bd07e678 100644 --- a/src/external/android-jni-wrap/wrap/android.content.h +++ b/src/external/android-jni-wrap/wrap/android.content.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -10,6 +10,7 @@ namespace wrap { namespace android::content { class ComponentName; +class ContentResolver; class Context; class Intent; } // namespace android::content @@ -18,6 +19,10 @@ namespace android::content::pm { class PackageManager; } // namespace android::content::pm +namespace android::database { +class Cursor; +} // namespace android::database + namespace android::os { class Bundle; } // namespace android::os @@ -74,6 +79,17 @@ class Context : public ObjectWrapperBase { */ pm::PackageManager getPackageManager(); + /*! + * Wrapper for the getContentResolver method + * + * Java prototype: + * `public abstract android.content.ContentResolver getContentResolver();` + * + * JNI signature: ()Landroid/content/ContentResolver; + * + */ + ContentResolver getContentResolver() const; + /*! * Wrapper for the getApplicationContext method * @@ -144,6 +160,7 @@ class Context : public ObjectWrapperBase { impl::StaticFieldId DISPLAY_SERVICE; impl::StaticFieldId WINDOW_SERVICE; jni::method_t getPackageManager; + jni::method_t getContentResolver; jni::method_t getApplicationContext; jni::method_t getClassLoader; jni::method_t startActivity; @@ -162,6 +179,7 @@ class Context : public ObjectWrapperBase { explicit Meta(bool deferDrop); }; }; + /*! * Wrapper for android.content.ComponentName objects. */ @@ -183,7 +201,7 @@ class ComponentName : public ObjectWrapperBase { * */ static ComponentName construct(std::string const &pkg, - std::string const &cls); + std::string const &className); /*! * Wrapper for a constructor @@ -195,7 +213,8 @@ class ComponentName : public ObjectWrapperBase { * JNI signature: (Landroid/content/Context;Ljava/lang/String;)V * */ - static ComponentName construct(Context const &pkg, std::string const &cls); + static ComponentName construct(Context const &context, + std::string const &className); /*! * Wrapper for a constructor @@ -207,7 +226,7 @@ class ComponentName : public ObjectWrapperBase { * JNI signature: (Landroid/content/Context;Ljava/lang/Class;)V * */ - static ComponentName construct(Context const &pkg, + static ComponentName construct(Context const &context, java::lang::Class const &cls); /*! @@ -234,7 +253,7 @@ class ComponentName : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -242,6 +261,7 @@ class ComponentName : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.content.Intent objects. */ @@ -263,20 +283,6 @@ class Intent : public ObjectWrapperBase { */ static int32_t FLAG_ACTIVITY_NEW_TASK(); -#if 0 - // disabled because of zero-length array warning in jnipp - /*! - * Wrapper for a constructor - * - * Java prototype: - * `public android.content.Intent();` - * - * JNI signature: ()V - * - */ - static Intent construct(); -#endif - /*! * Wrapper for a constructor * @@ -286,7 +292,7 @@ class Intent : public ObjectWrapperBase { * JNI signature: (Landroid/content/Intent;)V * */ - static Intent construct(Intent &intent); + static Intent construct(Intent const &intent); /*! * Wrapper for a constructor @@ -354,7 +360,6 @@ class Intent : public ObjectWrapperBase { */ struct Meta : public MetaBase { impl::StaticFieldId FLAG_ACTIVITY_NEW_TASK; - jni::method_t init; jni::method_t init1; jni::method_t init2; jni::method_t init3; @@ -366,7 +371,7 @@ class Intent : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -374,6 +379,91 @@ class Intent : public ObjectWrapperBase { Meta(); }; }; + +/*! + * Wrapper for android.content.ContentResolver objects. + */ +class ContentResolver : public ObjectWrapperBase { + public: + using ObjectWrapperBase::ObjectWrapperBase; + static constexpr const char *getTypeName() noexcept { + return "android/content/ContentResolver"; + } + + /*! + * Wrapper for the query method - overload added in API level 1 + * + * Java prototype: + * `public final android.database.Cursor query(android.net.Uri, + * java.lang.String[], java.lang.String, java.lang.String[], + * java.lang.String);` + * + * JNI signature: + * (Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor; + * + */ + database::Cursor query(jni::Object const &uri, + jni::Array const &projection, + std::string const &selection, + jni::Array const &selectionArgs, + std::string const &sortOrder); + + /*! + * Wrapper for the query method - overload added in API level 16 + * + * Java prototype: + * `public final android.database.Cursor query(android.net.Uri, + * java.lang.String[], java.lang.String, java.lang.String[], + * java.lang.String, android.os.CancellationSignal);` + * + * JNI signature: + * (Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/database/Cursor; + * + */ + database::Cursor query(jni::Object const &uri, + jni::Array const &projection, + std::string const &selection, + jni::Array const &selectionArgs, + std::string const &sortOrder, + jni::Object const &cancellationSignal); + + /*! + * Wrapper for the query method - overload added in API level 26 + * + * Java prototype: + * `public final android.database.Cursor query(android.net.Uri, + * java.lang.String[], android.os.Bundle, android.os.CancellationSignal);` + * + * JNI signature: + * (Landroid/net/Uri;[Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/database/Cursor; + * + */ + database::Cursor query(jni::Object const &uri, + jni::Array const &projection, + os::Bundle const &queryArgs, + jni::Object const &cancellationSignal); + + /*! + * Class metadata + */ + struct Meta : public MetaBaseDroppable { + jni::method_t query; + jni::method_t query1; + jni::method_t query2; + + /*! + * Singleton accessor + */ + static Meta &data() { + static Meta instance{}; + return instance; + } + + private: + Meta(); + }; +}; + } // namespace android::content } // namespace wrap #include "android.content.impl.h" 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 f1e88b126..09d2d79d5 100644 --- a/src/external/android-jni-wrap/wrap/android.content.impl.h +++ b/src/external/android-jni-wrap/wrap/android.content.impl.h @@ -1,10 +1,12 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once #include "android.content.pm.h" +#include "android.database.h" #include "android.os.h" #include "java.lang.h" #include @@ -12,8 +14,6 @@ namespace wrap { namespace android::content { inline std::string Context::DISPLAY_SERVICE() { - // Defer dropping the class ref to avoid having to do two class lookups - // by name for this static field. Instead, drop it before we return. auto &data = Meta::data(true); auto ret = get(data.DISPLAY_SERVICE, data.clazz()); data.dropClassRef(); @@ -21,8 +21,6 @@ inline std::string Context::DISPLAY_SERVICE() { } inline std::string Context::WINDOW_SERVICE() { - // Defer dropping the class ref to avoid having to do two class lookups - // by name for this static field. Instead, drop it before we return. auto &data = Meta::data(true); auto ret = get(data.WINDOW_SERVICE, data.clazz()); data.dropClassRef(); @@ -35,6 +33,12 @@ inline pm::PackageManager Context::getPackageManager() { object().call(Meta::data().getPackageManager)); } +inline ContentResolver Context::getContentResolver() const { + assert(!isNull()); + return ContentResolver( + object().call(Meta::data().getContentResolver)); +} + inline Context Context::getApplicationContext() { assert(!isNull()); return Context( @@ -65,40 +69,35 @@ inline Context Context::createPackageContext(std::string const &packageName, return Context(object().call(Meta::data().createPackageContext, packageName, flags)); } + inline ComponentName ComponentName::construct(std::string const &pkg, - std::string const &cls) { + std::string const &className) { return ComponentName( - Meta::data().clazz().newInstance(Meta::data().init, pkg, cls)); + Meta::data().clazz().newInstance(Meta::data().init, pkg, className)); } -inline ComponentName ComponentName::construct(Context const &pkg, - std::string const &cls) { - return ComponentName(Meta::data().clazz().newInstance(Meta::data().init1, - pkg.object(), cls)); +inline ComponentName ComponentName::construct(Context const &context, + std::string const &className) { + return ComponentName(Meta::data().clazz().newInstance( + Meta::data().init1, context.object(), className)); } -inline ComponentName ComponentName::construct(Context const &pkg, +inline ComponentName ComponentName::construct(Context const &context, java::lang::Class const &cls) { return ComponentName(Meta::data().clazz().newInstance( - Meta::data().init2, pkg.object(), cls.object())); + Meta::data().init2, context.object(), cls.object())); } inline ComponentName ComponentName::construct(jni::Object const &parcel) { return ComponentName( Meta::data().clazz().newInstance(Meta::data().init3, parcel)); } + inline int32_t Intent::FLAG_ACTIVITY_NEW_TASK() { return get(Meta::data().FLAG_ACTIVITY_NEW_TASK, Meta::data().clazz()); } -#if 0 -// disabled because of zero-length array warning in jnipp -inline Intent Intent::construct() { - return Intent(Meta::data().clazz().newInstance(Meta::data().init)); -} -#endif - -inline Intent Intent::construct(Intent &intent) { +inline Intent Intent::construct(Intent const &intent) { return Intent( Meta::data().clazz().newInstance(Meta::data().init1, intent.object())); } @@ -131,5 +130,35 @@ inline Intent Intent::setFlags(int32_t flags) { assert(!isNull()); return Intent(object().call(Meta::data().setFlags, flags)); } + +inline database::Cursor ContentResolver::query( + jni::Object const &uri, jni::Array const &projection, + std::string const &selection, jni::Array const &selectionArgs, + std::string const &sortOrder) { + assert(!isNull()); + return database::Cursor( + object().call(Meta::data().query, uri, projection, + selection, selectionArgs, sortOrder)); +} + +inline database::Cursor ContentResolver::query( + jni::Object const &uri, jni::Array const &projection, + std::string const &selection, jni::Array const &selectionArgs, + std::string const &sortOrder, jni::Object const &cancellationSignal) { + assert(!isNull()); + return database::Cursor(object().call( + Meta::data().query1, uri, projection, selection, selectionArgs, + sortOrder, cancellationSignal)); +} + +inline database::Cursor ContentResolver::query( + jni::Object const &uri, jni::Array const &projection, + os::Bundle const &queryArgs, jni::Object const &cancellationSignal) { + assert(!isNull()); + return database::Cursor( + object().call(Meta::data().query2, uri, projection, + queryArgs.object(), cancellationSignal)); +} + } // namespace android::content } // namespace wrap 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 3c378de67..3a4fe0ddd 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, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -40,9 +40,6 @@ PackageManager::Meta::Meta() getPackageInfo(classRef().getMethod( "getPackageInfo", "(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;")), - getPackageInfo1(classRef().getMethod( - "getPackageInfo", "(Landroid/content/pm/VersionedPackage;I)Landroid/" - "content/pm/PackageInfo;")), getApplicationInfo(classRef().getMethod( "getApplicationInfo", "(Ljava/lang/String;I)Landroid/content/pm/ApplicationInfo;")), 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 81a872a87..5cb9c7434 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, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -86,7 +86,7 @@ class PackageItemInfo : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -94,6 +94,7 @@ class PackageItemInfo : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.content.pm.ComponentInfo objects. */ @@ -113,7 +114,7 @@ class ComponentInfo : public PackageItemInfo { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -121,6 +122,7 @@ class ComponentInfo : public PackageItemInfo { Meta(); }; }; + /*! * Wrapper for android.content.pm.ServiceInfo objects. */ @@ -140,7 +142,7 @@ class ServiceInfo : public PackageItemInfo { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -148,6 +150,7 @@ class ServiceInfo : public PackageItemInfo { Meta(); }; }; + /*! * Wrapper for android.content.pm.ApplicationInfo objects. */ @@ -191,7 +194,7 @@ class ApplicationInfo : public PackageItemInfo { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -199,6 +202,7 @@ class ApplicationInfo : public PackageItemInfo { Meta(); }; }; + /*! * Wrapper for android.content.pm.PackageInfo objects. */ @@ -242,7 +246,7 @@ class PackageInfo : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -250,6 +254,7 @@ class PackageInfo : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.content.pm.ResolveInfo objects. */ @@ -281,7 +286,7 @@ class ResolveInfo : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -289,6 +294,7 @@ class ResolveInfo : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.content.pm.PackageManager objects. */ @@ -312,24 +318,6 @@ class PackageManager : public ObjectWrapperBase { */ PackageInfo getPackageInfo(std::string const &name, int32_t flags); -#if 0 - // Ambiguous overload until we wrap VersionedPackage - /*! - * Wrapper for the getPackageInfo method - * - * Java prototype: - * `public abstract android.content.pm.PackageInfo - * getPackageInfo(android.content.pm.VersionedPackage, int) throws - * android.content.pm.PackageManager$NameNotFoundException;` - * - * JNI signature: - * (Landroid/content/pm/VersionedPackage;I)Landroid/content/pm/PackageInfo; - * - */ - PackageInfo getPackageInfo(jni::Object &versionedPackage, int32_t flags); - -#endif - /*! * Wrapper for the getApplicationInfo method * @@ -354,7 +342,7 @@ class PackageManager : public ObjectWrapperBase { * JNI signature: (Landroid/content/Intent;I)Ljava/util/List; * */ - java::util::List queryIntentServices(Intent &intent, int32_t intParam); + java::util::List queryIntentServices(Intent const &intent, int32_t flags); enum { GET_META_DATA = 128, @@ -366,7 +354,6 @@ class PackageManager : public ObjectWrapperBase { */ struct Meta : public MetaBaseDroppable { jni::method_t getPackageInfo; - jni::method_t getPackageInfo1; jni::method_t getApplicationInfo; jni::method_t queryIntentServices; @@ -374,7 +361,7 @@ class PackageManager : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -382,6 +369,7 @@ class PackageManager : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::content::pm } // namespace wrap #include "android.content.pm.impl.h" 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 be6e5b377..84b405073 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,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -34,6 +35,7 @@ inline std::string ApplicationInfo::getPublicSourceDir() const { assert(!isNull()); return get(Meta::data().publicSourceDir, object()); } + inline ApplicationInfo PackageInfo::getApplicationInfo() const { assert(!isNull()); return get(Meta::data().applicationInfo, object()); @@ -43,10 +45,12 @@ inline std::string PackageInfo::getPackageName() const { assert(!isNull()); return get(Meta::data().packageName, object()); } + inline ServiceInfo ResolveInfo::getServiceInfo() const { assert(!isNull()); return get(Meta::data().serviceInfo, object()); } + inline PackageInfo PackageManager::getPackageInfo(std::string const &name, int32_t flags) { assert(!isNull()); @@ -54,17 +58,6 @@ inline PackageInfo PackageManager::getPackageInfo(std::string const &name, object().call(Meta::data().getPackageInfo, name, flags)); } -#if 0 -// Ambiguous overload until we wrap VersionedPackage -inline PackageInfo -PackageManager::getPackageInfo(jni::Object const &versionedPackage, - int32_t flags) { - assert(!isNull()); - return PackageInfo(object().call(Meta::data().getPackageInfo1, - versionedPackage, flags)); -} -#endif - inline ApplicationInfo PackageManager::getApplicationInfo(std::string const &packageName, int32_t flags) { @@ -73,11 +66,12 @@ PackageManager::getApplicationInfo(std::string const &packageName, Meta::data().getApplicationInfo, packageName, flags)); } -inline java::util::List PackageManager::queryIntentServices(Intent &intent, - int32_t intParam) { +inline java::util::List +PackageManager::queryIntentServices(Intent const &intent, int32_t flags) { assert(!isNull()); return java::util::List(object().call( - Meta::data().queryIntentServices, intent.object(), intParam)); + Meta::data().queryIntentServices, intent.object(), flags)); } + } // namespace android::content::pm } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.database.cpp b/src/external/android-jni-wrap/wrap/android.database.cpp new file mode 100644 index 000000000..f03e5730c --- /dev/null +++ b/src/external/android-jni-wrap/wrap/android.database.cpp @@ -0,0 +1,22 @@ +// Copyright 2020-2021, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +// Author: Ryan Pavlik + +#include "android.database.h" + +namespace wrap { +namespace android::database { +Cursor::Meta::Meta() + : MetaBaseDroppable(Cursor::getTypeName()), + getCount(classRef().getMethod("getCount", "()I")), + moveToFirst(classRef().getMethod("moveToFirst", "()Z")), + moveToNext(classRef().getMethod("moveToNext", "()Z")), + getColumnIndex( + classRef().getMethod("getColumnIndex", "(Ljava/lang/String;)I")), + getString(classRef().getMethod("getString", "(I)Ljava/lang/String;")), + getInt(classRef().getMethod("getInt", "(I)I")), + close(classRef().getMethod("close", "()V")) { + MetaBaseDroppable::dropClassRef(); +} +} // namespace android::database +} // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.database.h b/src/external/android-jni-wrap/wrap/android.database.h new file mode 100644 index 000000000..308fa2e03 --- /dev/null +++ b/src/external/android-jni-wrap/wrap/android.database.h @@ -0,0 +1,125 @@ +// Copyright 2020-2021, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +// Author: Ryan Pavlik + +#pragma once + +#include "ObjectWrapperBase.h" + +namespace wrap { +namespace android::database { +/*! + * Wrapper for android.database.Cursor objects. + */ +class Cursor : public ObjectWrapperBase { + public: + using ObjectWrapperBase::ObjectWrapperBase; + static constexpr const char *getTypeName() noexcept { + return "android/database/Cursor"; + } + + /*! + * Wrapper for the getCount method + * + * Java prototype: + * `public abstract int getCount();` + * + * JNI signature: ()I + * + */ + int32_t getCount(); + + /*! + * Wrapper for the moveToFirst method + * + * Java prototype: + * `public abstract boolean moveToFirst();` + * + * JNI signature: ()Z + * + */ + bool moveToFirst(); + + /*! + * Wrapper for the moveToNext method + * + * Java prototype: + * `public abstract boolean moveToNext();` + * + * JNI signature: ()Z + * + */ + bool moveToNext(); + + /*! + * Wrapper for the getColumnIndex method + * + * Java prototype: + * `public abstract int getColumnIndex(java.lang.String);` + * + * JNI signature: (Ljava/lang/String;)I + * + */ + int32_t getColumnIndex(std::string const &columnName); + + /*! + * Wrapper for the getString method + * + * Java prototype: + * `public abstract java.lang.String getString(int);` + * + * JNI signature: (I)Ljava/lang/String; + * + */ + std::string getString(int32_t column); + + /*! + * Wrapper for the getInt method + * + * Java prototype: + * `public abstract int getInt(int);` + * + * JNI signature: (I)I + * + */ + int32_t getInt(int32_t column); + + /*! + * Wrapper for the close method + * + * Java prototype: + * `public abstract void close();` + * + * JNI signature: ()V + * + */ + void close(); + + /*! + * Class metadata + */ + struct Meta : public MetaBaseDroppable { + jni::method_t getCount; + jni::method_t moveToFirst; + jni::method_t moveToNext; + jni::method_t getColumnIndex; + jni::method_t getString; + jni::method_t getInt; + jni::method_t close; + + /*! + * Singleton accessor + */ + static Meta &data() { + static Meta instance{}; + return instance; + } + + private: + Meta(); + }; +}; + +} // namespace android::database +} // namespace wrap +#include "android.database.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.database.impl.h b/src/external/android-jni-wrap/wrap/android.database.impl.h new file mode 100644 index 000000000..b48931efc --- /dev/null +++ b/src/external/android-jni-wrap/wrap/android.database.impl.h @@ -0,0 +1,48 @@ +// Copyright 2020-2021, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +// Author: Ryan Pavlik +// Inline implementations: do not include on its own! + +#pragma once + +#include + +namespace wrap { +namespace android::database { +inline int32_t Cursor::getCount() { + assert(!isNull()); + return object().call(Meta::data().getCount); +} + +inline bool Cursor::moveToFirst() { + assert(!isNull()); + return object().call(Meta::data().moveToFirst); +} + +inline bool Cursor::moveToNext() { + assert(!isNull()); + return object().call(Meta::data().moveToNext); +} + +inline int32_t Cursor::getColumnIndex(std::string const &columnName) { + assert(!isNull()); + return object().call(Meta::data().getColumnIndex, columnName); +} + +inline std::string Cursor::getString(int32_t column) { + assert(!isNull()); + return object().call(Meta::data().getString, column); +} + +inline int32_t Cursor::getInt(int32_t column) { + assert(!isNull()); + return object().call(Meta::data().getInt, column); +} + +inline void Cursor::close() { + assert(!isNull()); + return object().call(Meta::data().close); +} + +} // namespace android::database +} // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.graphics.cpp b/src/external/android-jni-wrap/wrap/android.graphics.cpp index 99809b737..54a33a8bb 100644 --- a/src/external/android-jni-wrap/wrap/android.graphics.cpp +++ b/src/external/android-jni-wrap/wrap/android.graphics.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.graphics.h b/src/external/android-jni-wrap/wrap/android.graphics.h index bbe35fa8a..3d0070ea0 100644 --- a/src/external/android-jni-wrap/wrap/android.graphics.h +++ b/src/external/android-jni-wrap/wrap/android.graphics.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -51,7 +51,7 @@ class Point : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -59,6 +59,7 @@ class Point : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::graphics } // namespace wrap #include "android.graphics.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.graphics.impl.h b/src/external/android-jni-wrap/wrap/android.graphics.impl.h index 30ba5bcf5..db38da785 100644 --- a/src/external/android-jni-wrap/wrap/android.graphics.impl.h +++ b/src/external/android-jni-wrap/wrap/android.graphics.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -15,5 +16,6 @@ inline int32_t Point::getY() const { assert(!isNull()); return get(Meta::data().y, object()); } + } // namespace android::graphics } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.os.cpp b/src/external/android-jni-wrap/wrap/android.os.cpp index bfa898305..2b5c43eeb 100644 --- a/src/external/android-jni-wrap/wrap/android.os.cpp +++ b/src/external/android-jni-wrap/wrap/android.os.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.os.h b/src/external/android-jni-wrap/wrap/android.os.h index 2ea3f5d4d..eb9a57e20 100644 --- a/src/external/android-jni-wrap/wrap/android.os.h +++ b/src/external/android-jni-wrap/wrap/android.os.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -71,7 +71,7 @@ class BaseBundle : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -79,6 +79,7 @@ class BaseBundle : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.os.Bundle objects. */ @@ -98,7 +99,7 @@ class Bundle : public BaseBundle { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -186,7 +187,7 @@ class ParcelFileDescriptor : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -194,6 +195,7 @@ class ParcelFileDescriptor : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::os } // namespace wrap #include "android.os.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.os.impl.h b/src/external/android-jni-wrap/wrap/android.os.impl.h index 6078d378e..d4f2e7e1f 100644 --- a/src/external/android-jni-wrap/wrap/android.os.impl.h +++ b/src/external/android-jni-wrap/wrap/android.os.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -49,5 +50,6 @@ inline void ParcelFileDescriptor::checkError() const { assert(!isNull()); return object().call(Meta::data().checkError); } + } // namespace android::os } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.provider.cpp b/src/external/android-jni-wrap/wrap/android.provider.cpp index 2648c4b05..fe7d22953 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, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.provider.h b/src/external/android-jni-wrap/wrap/android.provider.h index e139e3151..85290b333 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, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -40,7 +40,7 @@ class Settings : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -48,6 +48,7 @@ class Settings : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::provider } // namespace wrap #include "android.provider.impl.h" 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 066782847..618181564 100644 --- a/src/external/android-jni-wrap/wrap/android.provider.impl.h +++ b/src/external/android-jni-wrap/wrap/android.provider.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -9,5 +10,6 @@ namespace android::provider { inline std::string Settings::ACTION_VR_LISTENER_SETTINGS() { return get(Meta::data().ACTION_VR_LISTENER_SETTINGS, Meta::data().clazz()); } + } // namespace android::provider } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.service.vr.cpp b/src/external/android-jni-wrap/wrap/android.service.vr.cpp index a1381a404..535a6bbdb 100644 --- a/src/external/android-jni-wrap/wrap/android.service.vr.cpp +++ b/src/external/android-jni-wrap/wrap/android.service.vr.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.service.vr.h b/src/external/android-jni-wrap/wrap/android.service.vr.h index 65fa9b705..11a851d56 100644 --- a/src/external/android-jni-wrap/wrap/android.service.vr.h +++ b/src/external/android-jni-wrap/wrap/android.service.vr.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -52,7 +52,7 @@ class VrListenerService : public app::Service { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -60,6 +60,7 @@ class VrListenerService : public app::Service { Meta(); }; }; + } // namespace android::service::vr } // namespace wrap #include "android.service.vr.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.service.vr.impl.h b/src/external/android-jni-wrap/wrap/android.service.vr.impl.h index 45b7304d6..dcb1782f4 100644 --- a/src/external/android-jni-wrap/wrap/android.service.vr.impl.h +++ b/src/external/android-jni-wrap/wrap/android.service.vr.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -15,5 +16,6 @@ inline bool VrListenerService::isVrModePackageEnabled( context.object(), componentName.object()); } + } // namespace android::service::vr } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.util.cpp b/src/external/android-jni-wrap/wrap/android.util.cpp index 3c96d69a0..0a088289d 100644 --- a/src/external/android-jni-wrap/wrap/android.util.cpp +++ b/src/external/android-jni-wrap/wrap/android.util.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.util.h b/src/external/android-jni-wrap/wrap/android.util.h index 418b797f8..332acb408 100644 --- a/src/external/android-jni-wrap/wrap/android.util.h +++ b/src/external/android-jni-wrap/wrap/android.util.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -51,7 +51,7 @@ class DisplayMetrics : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -59,6 +59,7 @@ class DisplayMetrics : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::util } // namespace wrap #include "android.util.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.util.impl.h b/src/external/android-jni-wrap/wrap/android.util.impl.h index adfc8b4f4..bcaeb2df7 100644 --- a/src/external/android-jni-wrap/wrap/android.util.impl.h +++ b/src/external/android-jni-wrap/wrap/android.util.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -15,5 +16,6 @@ inline int32_t DisplayMetrics::getWidthPixels() const { assert(!isNull()); return get(Meta::data().widthPixels, object()); } + } // namespace android::util } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.view.cpp b/src/external/android-jni-wrap/wrap/android.view.cpp index 3934ea31e..7afe038ae 100644 --- a/src/external/android-jni-wrap/wrap/android.view.cpp +++ b/src/external/android-jni-wrap/wrap/android.view.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.view.h b/src/external/android-jni-wrap/wrap/android.view.h index f958085c9..d58fa101e 100644 --- a/src/external/android-jni-wrap/wrap/android.view.h +++ b/src/external/android-jni-wrap/wrap/android.view.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -66,7 +66,7 @@ class Display : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -74,6 +74,7 @@ class Display : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.view.Surface objects. */ @@ -105,7 +106,7 @@ class Surface : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -113,6 +114,7 @@ class Surface : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for android.view.SurfaceHolder objects. */ @@ -144,7 +146,7 @@ class SurfaceHolder : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -152,6 +154,7 @@ class SurfaceHolder : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::view } // namespace wrap #include "android.view.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.view.impl.h b/src/external/android-jni-wrap/wrap/android.view.impl.h index caf34c570..5e91091c1 100644 --- a/src/external/android-jni-wrap/wrap/android.view.impl.h +++ b/src/external/android-jni-wrap/wrap/android.view.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -19,13 +20,16 @@ inline void Display::getRealMetrics(util::DisplayMetrics &out_displayMetrics) { return object().call(Meta::data().getRealMetrics, out_displayMetrics.object()); } + inline bool Surface::isValid() const { assert(!isNull()); return object().call(Meta::data().isValid); } + inline Surface SurfaceHolder::getSurface() { assert(!isNull()); return Surface(object().call(Meta::data().getSurface)); } + } // namespace android::view } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/android.widget.cpp b/src/external/android-jni-wrap/wrap/android.widget.cpp index 8da994786..073aacb68 100644 --- a/src/external/android-jni-wrap/wrap/android.widget.cpp +++ b/src/external/android-jni-wrap/wrap/android.widget.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/android.widget.h b/src/external/android-jni-wrap/wrap/android.widget.h index 52289c2f3..630474c13 100644 --- a/src/external/android-jni-wrap/wrap/android.widget.h +++ b/src/external/android-jni-wrap/wrap/android.widget.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -74,7 +74,7 @@ class Toast : public ObjectWrapperBase { * */ static Toast makeText(content::Context const &context, - std::string const &stringParam, int32_t duration); + jni::Object const &text, int32_t duration); /*! * Wrapper for the makeText static method @@ -86,7 +86,7 @@ class Toast : public ObjectWrapperBase { * JNI signature: (Landroid/content/Context;II)Landroid/widget/Toast; * */ - static Toast makeText(content::Context &context, int32_t resId, + static Toast makeText(content::Context const &context, int32_t resId, int32_t duration); /*! @@ -103,7 +103,7 @@ class Toast : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -111,6 +111,7 @@ class Toast : public ObjectWrapperBase { Meta(); }; }; + } // namespace android::widget } // namespace wrap #include "android.widget.impl.h" diff --git a/src/external/android-jni-wrap/wrap/android.widget.impl.h b/src/external/android-jni-wrap/wrap/android.widget.impl.h index ecb511603..370a1566a 100644 --- a/src/external/android-jni-wrap/wrap/android.widget.impl.h +++ b/src/external/android-jni-wrap/wrap/android.widget.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -22,15 +23,16 @@ inline void Toast::show() const { } inline Toast Toast::makeText(content::Context const &context, - std::string const &stringParam, int32_t duration) { + jni::Object const &text, int32_t duration) { return Toast(Meta::data().clazz().call( - Meta::data().makeText, context.object(), stringParam, duration)); + Meta::data().makeText, context.object(), text, duration)); } -inline Toast Toast::makeText(content::Context &context, int32_t resId, +inline Toast Toast::makeText(content::Context const &context, int32_t resId, int32_t duration) { return Toast(Meta::data().clazz().call( Meta::data().makeText1, context.object(), resId, duration)); } + } // namespace android::widget } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/dalvik.system.cpp b/src/external/android-jni-wrap/wrap/dalvik.system.cpp deleted file mode 100644 index 671773395..000000000 --- a/src/external/android-jni-wrap/wrap/dalvik.system.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020, Collabora, Ltd. -// SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik - -#include "dalvik.system.h" - -namespace wrap { -namespace dalvik::system { -DexClassLoader::Meta::Meta() - : MetaBase(DexClassLoader::getTypeName()), - init(classRef().getMethod("", - "(Ljava/lang/String;Ljava/lang/String;Ljava/" - "lang/String;Ljava/lang/ClassLoader;)V")) {} -} // namespace dalvik::system -} // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/dalvik.system.h b/src/external/android-jni-wrap/wrap/dalvik.system.h deleted file mode 100644 index b3775f9ac..000000000 --- a/src/external/android-jni-wrap/wrap/dalvik.system.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2020, Collabora, Ltd. -// SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik - -#pragma once - -#include "ObjectWrapperBase.h" - -namespace wrap { -namespace dalvik::system { -class DexClassLoader; -} // namespace dalvik::system - -namespace java::lang { -class ClassLoader; -} // namespace java::lang - -} // namespace wrap - -namespace wrap { -namespace dalvik::system { -/*! - * Wrapper for dalvik.system.DexClassLoader objects. - */ -class DexClassLoader : public ObjectWrapperBase { - public: - using ObjectWrapperBase::ObjectWrapperBase; - static constexpr const char *getTypeName() noexcept { - return "dalvik/system/DexClassLoader"; - } - - /*! - * Wrapper for a constructor - * - * Java prototype: - * `public dalvik.system.DexClassLoader(java.lang.String, java.lang.String, - * java.lang.String, java.lang.ClassLoader);` - * - * JNI signature: - * (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V - * - */ - static DexClassLoader construct(std::string const &searchPath, - std::string const &nativeSearchPath, - jni::Object parentClassLoader); - - /*! - * Class metadata - */ - struct Meta : public MetaBase { - jni::method_t init; - - /*! - * Singleton accessor - */ - static Meta &data() { - static Meta instance; - return instance; - } - - private: - Meta(); - }; -}; -} // namespace dalvik::system -} // namespace wrap -#include "dalvik.system.impl.h" diff --git a/src/external/android-jni-wrap/wrap/dalvik.system.impl.h b/src/external/android-jni-wrap/wrap/dalvik.system.impl.h deleted file mode 100644 index c23a80839..000000000 --- a/src/external/android-jni-wrap/wrap/dalvik.system.impl.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2020, Collabora, Ltd. -// SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik - -#pragma once - -#include "java.lang.h" -#include - -namespace wrap { -namespace dalvik::system { -inline DexClassLoader -DexClassLoader::construct(std::string const &searchPath, - std::string const &nativeSearchPath, - jni::Object parentClassLoader) { - return DexClassLoader{ - Meta::data().clazz().newInstance(Meta::data().init, searchPath, "", - nativeSearchPath, parentClassLoader)}; -} -} // namespace dalvik::system -} // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/java.lang.cpp b/src/external/android-jni-wrap/wrap/java.lang.cpp index 523bbaaee..980fb57f0 100644 --- a/src/external/android-jni-wrap/wrap/java.lang.cpp +++ b/src/external/android-jni-wrap/wrap/java.lang.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -13,9 +13,6 @@ Class::Meta::Meta() forName1(classRef().getStaticMethod( "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;")), - forName2(classRef().getStaticMethod( - "forName", - "(Ljava/lang/Module;Ljava/lang/String;)Ljava/lang/Class;")), getCanonicalName( classRef().getMethod("getCanonicalName", "()Ljava/lang/String;")) {} ClassLoader::Meta::Meta() diff --git a/src/external/android-jni-wrap/wrap/java.lang.h b/src/external/android-jni-wrap/wrap/java.lang.h index 56541411b..cfd112b11 100644 --- a/src/external/android-jni-wrap/wrap/java.lang.h +++ b/src/external/android-jni-wrap/wrap/java.lang.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -36,7 +36,7 @@ class Class : public ObjectWrapperBase { * JNI signature: (Ljava/lang/String;)Ljava/lang/Class; * */ - static Class forName(std::string &stringParam); + static Class forName(std::string const &name); /*! * Wrapper for the forName static method @@ -50,23 +50,11 @@ class Class : public ObjectWrapperBase { * */ static Class forName(std::string const &name, bool initialize, - jni::Object classLoader); + ClassLoader const &classLoader); //! @overload static Class forName(jstring name, bool initialize, jni::Object classLoader); - /*! - * Wrapper for the forName static method - * - * Java prototype: - * `public static java.lang.Class forName(java.lang.Module, - * java.lang.String);` - * - * JNI signature: (Ljava/lang/Module;Ljava/lang/String;)Ljava/lang/Class; - * - */ - static Class forName(jni::Object const &module, std::string const &name); - /*! * Wrapper for the getCanonicalName method * @@ -84,14 +72,13 @@ class Class : public ObjectWrapperBase { struct Meta : public MetaBase { jni::method_t forName; jni::method_t forName1; - jni::method_t forName2; jni::method_t getCanonicalName; /*! * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -99,6 +86,7 @@ class Class : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for java.lang.ClassLoader objects. */ @@ -143,7 +131,7 @@ class ClassLoader : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -151,6 +139,7 @@ class ClassLoader : public ObjectWrapperBase { Meta(); }; }; + /*! * Wrapper for java.lang.System objects. */ @@ -182,7 +171,7 @@ class System : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -190,6 +179,7 @@ class System : public ObjectWrapperBase { Meta(); }; }; + } // namespace java::lang } // namespace wrap #include "java.lang.impl.h" diff --git a/src/external/android-jni-wrap/wrap/java.lang.impl.h b/src/external/android-jni-wrap/wrap/java.lang.impl.h index 8c95ea8de..324bfc1b4 100644 --- a/src/external/android-jni-wrap/wrap/java.lang.impl.h +++ b/src/external/android-jni-wrap/wrap/java.lang.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -8,15 +9,15 @@ namespace wrap { namespace java::lang { -inline Class Class::forName(std::string &stringParam) { - return Class(Meta::data().clazz().call(Meta::data().forName, - stringParam)); +inline Class Class::forName(std::string const &name) { + return Class( + Meta::data().clazz().call(Meta::data().forName, name)); } inline Class Class::forName(std::string const &name, bool initialize, - jni::Object classLoader) { + ClassLoader const &classLoader) { return Class(Meta::data().clazz().call( - Meta::data().forName1, name, initialize, classLoader)); + Meta::data().forName1, name, initialize, classLoader.object())); } inline Class Class::forName(jstring name, bool initialize, @@ -25,12 +26,6 @@ inline Class Class::forName(jstring name, bool initialize, Meta::data().forName, name, initialize, classLoader)}; } -inline Class Class::forName(jni::Object const &module, - std::string const &name) { - return Class(Meta::data().clazz().call(Meta::data().forName2, - module, name)); -} - inline std::string Class::getCanonicalName() { assert(!isNull()); return object().call(Meta::data().getCanonicalName); @@ -55,5 +50,6 @@ inline std::string System::mapLibraryName(std::string const &name) { return Meta::data().clazz().call(Meta::data().mapLibraryName, name); } + } // namespace java::lang } // namespace wrap diff --git a/src/external/android-jni-wrap/wrap/java.util.cpp b/src/external/android-jni-wrap/wrap/java.util.cpp index 1582bed56..8ee0e0818 100644 --- a/src/external/android-jni-wrap/wrap/java.util.cpp +++ b/src/external/android-jni-wrap/wrap/java.util.cpp @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik diff --git a/src/external/android-jni-wrap/wrap/java.util.h b/src/external/android-jni-wrap/wrap/java.util.h index 1cda61aec..863f7c682 100644 --- a/src/external/android-jni-wrap/wrap/java.util.h +++ b/src/external/android-jni-wrap/wrap/java.util.h @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik @@ -51,7 +51,7 @@ class List : public ObjectWrapperBase { * Singleton accessor */ static Meta &data() { - static Meta instance; + static Meta instance{}; return instance; } @@ -59,6 +59,7 @@ class List : public ObjectWrapperBase { Meta(); }; }; + } // namespace java::util } // namespace wrap #include "java.util.impl.h" diff --git a/src/external/android-jni-wrap/wrap/java.util.impl.h b/src/external/android-jni-wrap/wrap/java.util.impl.h index d394388ee..e40ad7224 100644 --- a/src/external/android-jni-wrap/wrap/java.util.impl.h +++ b/src/external/android-jni-wrap/wrap/java.util.impl.h @@ -1,6 +1,7 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 // Author: Ryan Pavlik +// Inline implementations: do not include on its own! #pragma once @@ -15,5 +16,6 @@ inline jni::Object List::get(int32_t index) const { assert(!isNull()); return object().call(Meta::data().get, index); } + } // namespace java::util } // namespace wrap