summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/androidjnimain.cpp
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@theqtcompany.com>2014-10-30 19:23:40 +0100
committerChristian Stromme <christian.stromme@digia.com>2014-11-03 18:25:21 +0100
commit0df7ab1cabfd84c88b290cf784be6d51fb4f656a (patch)
tree7cda2d08803933fe661d70d3646bc2be18a61e0d /src/plugins/platforms/android/androidjnimain.cpp
parent078380df1e14ac82b3cf3ad66ae50d5351709537 (diff)
Android: Remove AttachedJNIEnv class.
The JNI environment should be managed by QJNIEnvironmentPrivate directly or through QJNIObjectPrivate. There is also a clear difference between calls coming from or going into Java code. Calls coming from Java already comes with the 'right' environment and in most cases no extra considerations or set-up is needed. Change-Id: I92d935ddfb70332041869185d5a92438930ff9b9 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 11f0bc5ffe..d1e78dfe5d 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -80,7 +80,6 @@ static jmethodID m_createBitmapMethodID = Q_NULLPTR;
static jobject m_ARGB_8888_BitmapConfigValue = Q_NULLPTR;
static jobject m_RGB_565_BitmapConfigValue = Q_NULLPTR;
-jmethodID m_setFullScreenMethodID = Q_NULLPTR;
static bool m_statusBarShowing = true;
static jclass m_bitmapDrawableClass = Q_NULLPTR;
@@ -182,13 +181,7 @@ namespace QtAndroid
if (m_statusBarShowing)
return;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv) {
- qWarning("Failed to get JNI Environment.");
- return;
- }
-
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, m_setFullScreenMethodID, false);
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", false);
m_statusBarShowing = true;
}
@@ -197,13 +190,7 @@ namespace QtAndroid
if (!m_statusBarShowing)
return;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv) {
- qWarning("Failed to get JNI Environment.");
- return;
- }
-
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, m_setFullScreenMethodID, true);
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", true);
m_statusBarShowing = false;
}
@@ -453,16 +440,9 @@ static void *startMainMethod(void */*data*/)
if (res < 0)
qWarning() << "dlclose failed:" << dlerror();
}
- m_mainLibraryHnd = Q_NULLPTR;
- m_main = Q_NULLPTR;
- QtAndroid::AttachedJNIEnv env;
- if (!env.jniEnv)
- return 0;
- if (m_applicationClass) {
- jmethodID quitApp = env.jniEnv->GetStaticMethodID(m_applicationClass, "quitApp", "()V");
- env.jniEnv->CallStaticVoidMethod(m_applicationClass, quitApp);
- }
+ if (m_applicationClass)
+ QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "quitApp", "()V");
return 0;
}
@@ -723,7 +703,6 @@ static int registerNatives(JNIEnv *env)
jclass clazz;
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/QtNative");
m_applicationClass = static_cast<jclass>(env->NewGlobalRef(clazz));
- GET_AND_CHECK_STATIC_METHOD(m_setFullScreenMethodID, m_applicationClass, "setFullScreen", "(Z)V");
if (env->RegisterNatives(m_applicationClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
__android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed");