summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-07-20 15:51:07 +0300
committerBogDan Vatra <bogdan@kdab.com>2016-07-20 13:04:14 +0000
commit8b79fc4ee1c0510c13dc6f1494f37727e3f8c0cf (patch)
tree7f5b5e056ddea5b0cbffe7fde1cdbff3da920ea7
parent90eb1a41702bf748ac3f356d8ce04496f75ecb64 (diff)
downloadqtsensors-8b79fc4ee1c0510c13dc6f1494f37727e3f8c0cf.tar.gz
Make sure JNI_OnLoad is not called more than once
Since Android 5.0 Google introduce a nasty bug[1] which calls JNI_OnLoad more than once. Basically every time when a library is loaded JNI_OnLoad is called if found, but it calls *again* JNI_OnLoad of its .so dependencies! [1] Workaround https://code.google.com/p/android/issues/detail?id=215069 Change-Id: I34728572bc279581b8c95c42c206ed104bfc09a5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/plugins/sensors/android/src/androidjnisensors.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/sensors/android/src/androidjnisensors.cpp b/src/plugins/sensors/android/src/androidjnisensors.cpp
index 98f408a..ce69e75 100644
--- a/src/plugins/sensors/android/src/androidjnisensors.cpp
+++ b/src/plugins/sensors/android/src/androidjnisensors.cpp
@@ -241,6 +241,11 @@ static bool registerNatives(JNIEnv *env)
Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
{
+ static bool initialized = false;
+ if (initialized)
+ return JNI_VERSION_1_6;
+ initialized = true;
+
typedef union {
JNIEnv *nativeEnvironment;
void *venv;