diff options
author | BogDan Vatra <bogdan@kdab.com> | 2016-07-20 15:46:32 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2016-07-20 13:19:40 +0000 |
commit | 09d30048e6cf8a86507bda1872fd7d9f653ec9ed (patch) | |
tree | 27f619f5a1bb134a247dcf411f4720a44a7d3ed1 /src/nfc | |
parent | 19e3ad566f77a5040781d5d9776b11afa8c49032 (diff) |
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: I2894dd24afa9c51582f20ab44d83e9ce86751716
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/nfc')
-rw-r--r-- | src/nfc/android/androidjninfc.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nfc/android/androidjninfc.cpp b/src/nfc/android/androidjninfc.cpp index a95e2f98..77ef2ee7 100644 --- a/src/nfc/android/androidjninfc.cpp +++ b/src/nfc/android/androidjninfc.cpp @@ -90,6 +90,11 @@ QT_END_ANDROIDNFC_NAMESPACE Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) { + static bool initialized = false; + if (initialized) + return JNI_VERSION_1_6; + initialized = true; + JNIEnv* env; if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { return -1; |