summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidsystemlocale.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-26 16:30:36 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-27 17:44:35 +0200
commit703614f03b73fbcc63d8315bb6a2a86156476341 (patch)
tree7a674384504f69c13b08780922fdeca6f8d04fd9 /src/plugins/platforms/android/qandroidsystemlocale.cpp
parentd44aae13589074752ab74d796a7ade87261bceb4 (diff)
Android: replace QtAndroid::activity/service with QtAndroidPrivate
There's no need for both, and QtAndroidPrivate is a documented namespace. Replace all calls to QtAndroid::activity/service with QtAndroidPrivate equivalents, and drop the QtAndroid version. Since we no longer store a global copy of the activity and service, we can drop the reference right away. This comes with a bit of overhead - QtAndroid::activity returned a copy of a global static QJniObject (62cb5589b3723fe8162e190cd54d9c78929b98d2, after which declared QtJniTypes became QJniObjects), while QtAndroidPrivate::activity returns a newly created QtJniTypes::Activity on each call. This however makes it also safer, as the QJniObject is then associated with the calling thread's JNI environment, and we can optimize critical code paths where it's safe to do so later. Also, QtAndroid's activity object was never updated, while QtAndroidPrivate's activity is updated in the updateNativeActivity native method. Change-Id: I36c5b504eac52d9e28b4c6b265daab8fedc877e2 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidsystemlocale.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidsystemlocale.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/plugins/platforms/android/qandroidsystemlocale.cpp b/src/plugins/platforms/android/qandroidsystemlocale.cpp
index 858934b1f8..ab1ece7d39 100644
--- a/src/plugins/platforms/android/qandroidsystemlocale.cpp
+++ b/src/plugins/platforms/android/qandroidsystemlocale.cpp
@@ -21,11 +21,9 @@ void QAndroidSystemLocale::getLocaleFromJava() const
QWriteLocker locker(&m_lock);
QJniObject javaLocaleObject;
- QJniObject javaActivity(QtAndroid::activity());
- if (!javaActivity.isValid())
- javaActivity = QtAndroid::service();
- if (javaActivity.isValid()) {
- QJniObject resources = javaActivity.callObjectMethod("getResources", "()Landroid/content/res/Resources;");
+ const QJniObject javaContext = QtAndroidPrivate::context();
+ if (javaContext.isValid()) {
+ QJniObject resources = javaContext.callObjectMethod("getResources", "()Landroid/content/res/Resources;");
QJniObject configuration = resources.callObjectMethod("getConfiguration", "()Landroid/content/res/Configuration;");
javaLocaleObject = configuration.getObjectField("locale", "Ljava/util/Locale;");