summaryrefslogtreecommitdiff
path: root/src/plugins/platforms/android/androidjnimain.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-04-26 13:19:46 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-05-17 00:34:06 +0200
commit367092d7e02bfe0054b78e856b7addbdb56aae2e (patch)
treef17793c691da879973689d9cab355ea3f2f1e4e1 /src/plugins/platforms/android/androidjnimain.cpp
parentf6e89e901ba718d64b50f79f3b1b327a7f6a0211 (diff)
downloadqtbase-367092d7e02bfe0054b78e856b7addbdb56aae2e.tar.gz
Return specific types for frequently used Java objects
This allows us to specialize JNI type signature templates for e.g. the context object, which in Java signatures is "android/content/Context". Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing. The types declared this way live in the QtJniTypes namespace, and transparently convert from and to jobject. Since jobject is a typedef to _jobject* we cannot create a subclass. Use a "Object" superclass that we can provide a QJniObject constructor for so that we don't require the QJniObject declaration to be able to use the macro. The APIs in the QNativeInterface namespace doesn't provide source or binary compatibility guarantees, so we can change the return types. Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 0f417cdb23..3b5e656630 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -43,9 +43,9 @@ static jmethodID m_loadClassMethodID = nullptr;
static AAssetManager *m_assetManager = nullptr;
static jobject m_assets = nullptr;
static jobject m_resourcesObj = nullptr;
-static jobject m_activityObject = nullptr;
+static QtJniTypes::Activity m_activityObject = nullptr;
static jmethodID m_createSurfaceMethodID = nullptr;
-static jobject m_serviceObject = nullptr;
+static QtJniTypes::Service m_serviceObject = nullptr;
static jmethodID m_setSurfaceGeometryMethodID = nullptr;
static jmethodID m_destroySurfaceMethodID = nullptr;
@@ -159,12 +159,12 @@ namespace QtAndroid
return m_applicationClass;
}
- jobject activity()
+ QtJniTypes::Activity activity()
{
return m_activityObject;
}
- jobject service()
+ QtJniTypes::Service service()
{
return m_serviceObject;
}