summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qjnihelpers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Android: add missing extras native methods impls and registrationAssam Boudjelthia2023-11-031-2/+6
| | | | | | | | | | This should have been done when the extras where moved to qtbase, it went under the rug and was forgotten. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-114971 Change-Id: Id7831a8bab8bedc1f869b9fc8bfc72acc3cca7a2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Android: replace QtAndroid::activity/service with QtAndroidPrivateVolker Hilsheimer2023-10-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Android: move input handling from QtActivityDelegate to separate classAssam Boudjelthia2023-10-181-62/+0
| | | | | | | | | | | | | | | | | | | | | | | | To further simplify the code and logic of the delegate, move keyboard input code to separate class. Make an input delegate available under the QtActivityDelegate to allow classes like QtNative and the Activity to access that. For now, it's okay to leave access from QtNative to that, but for future even that should be simplified and the Activity should be accessing that directly. For the case where the QtInputDelegate needs access to QtActivityDelegate, for now namely updateFullScreen(), a new Listener is implemented to be implemented under QtActivityDelegate. Along the way use newer JNI APIs under C++ QtAndroidInput. Don't make them static methods, so that it can be possible later to do various keyboard operations to specific activity and not a global one. Task-number: QTBUG-114593 Task-number: QTBUG-118077 Change-Id: I110b897f6f16d0ae5f5a645551b4a82e8ad3f2fb Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* QJniHelpers: replace some Q_GLOBAL_STATIC with QBasic* staticsMarc Mutz2023-01-061-13/+14
| | | | | | | | | | | | | | | For both QMutex and QAtomicInt, we have QBasic{Mutex,AtomicInt}, which are PODs, and therefore constant-initialized. Q_GLOBAL_STATIC, otoh, forces dynamic initialization, so don't use it. Raw pointers don't need Q_GLOBAL_STATIC, either. Patch up users. Instead of adding &'s to QMutexLocker arguments, port directly to qt_scoped_lock, which takes by reference. Change-Id: I1a13db2a5e88a52d4338a174a80522a3f5e58fa2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-2/+2
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* JNI: match the declaration from jni.hThiago Macieira2022-07-201-1/+1
| | | | | | | | | | Happens when we switch to protected visibility. qjnihelpers.cpp:398:1: error: visibility does not match previous declaration jni.h:1112:1: note: previous attribute is here Change-Id: I3859764fed084846bcb0fffd17036098322e6b8d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QJniHelpers: don't rely on qreadwritelock.h transitive includeMarc Mutz2022-05-171-0/+1
| | | | | | | | | | | ... from qcoreapplication_p.h Amends 5fd6704091febcc4abbc8d7ce06a393572524fa5. Pick-to: 6.3 Change-Id: I00bda35aa7bfd590105d7fe275af181ba7b53446 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Return specific types for frequently used Java objectsVolker Hilsheimer2022-05-171-3/+3
| | | | | | | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix restart QtActivitySamuel Mira2022-04-271-1/+41
| | | | | | | | | | | | | | | | | | Previously, a restart of QtActivity on Android would make the application fail with a blank screen. That happened because the QtActivity tried to reload the whole application and failed. With this patch, the QtActivity detects if the application is restarting by checking if QtNative and QtActivityDelegate are live and updates the connections on those objects accordingly. It allows the application to continue as before. In case that is not possible, the QtActivity will restart the application. Fixes: QTBUG-38971 Fixes: QTBUG-102298 Pick-to: 5.15 6.2 6.3 Change-Id: Id500d20b185d57b39d45d34eeaa99745a3c2b95b Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Exploit the new macro varargs form of Q_GLOBAL_STATICEdward Welbourne2022-04-221-2/+2
| | | | | | | | Convert various uses of Q_GLOBAL_STATIC_WITH_ARGS() to the less verbose form the recent reworking makes possible. Change-Id: I57820660b5d00d39bf54b5a08cb921ebaec57c7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: Fix deadlock caused by a race between permissions query and IMJarkko Koivikko2022-04-051-0/+12
| | | | | | | | | | | | | | | | Android permissions query blocks Qt main thread. If the input method was activated before the permissions query started, android would try to invoke input method before returning back to permissions query. This will cause a deadlock. Fix the issue by moving the deadlock counter to Qt core and incrementing the value before the permissions query. This will prevent the input method queries to enter Qt main thread. Fixes: QTBUG-99484 Pick-to: 6.2 6.3 6.3.0 Change-Id: I54ea59578880cde4095c26fa2a6a264c4dc1b7ff Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Re-apply "Remove old Android code that have now has alternative public APIs"Assam Boudjelthia2021-07-011-201/+3
| | | | | | | | | | | | | This reverts commit 046d819e2e25d2752b3898dd775eeb560e24b4ce. Since qtandroidextras is now removed from qt5, there should no longer be a dependency issue in CI. Pick-to: 6.2 Change-Id: I3b8ed409eeb0ad6c7bb3303ec08e672739c5b2ed Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Revert "Remove old Android code that have now has alternative public APIs"Jani Heikkinen2021-06-161-3/+201
| | | | | | | | | | | | | This reverts commit 03eb44394e4cdf3d2a9aa7be632b487313519fbb. Reason for revert: This breaks the dependecy update round in dev now. The revert can be reverted again after 1) Full dependency round is succeed in 'dev' 2) Android extras submodule has been removed from qt5.git#dev (7aa41d22fa485f212aebbef500ea91921c7bc38b) 3)qtmultimedia has been ported to use new api instead of this old one 4) Full dependency round with all above is succeed in 'dev' Change-Id: I23241d2a90307074ecfc9573d2b58baba1874cfc Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Remove old Android code that have now has alternative public APIsAssam Boudjelthia2021-06-111-201/+3
| | | | | | | | | | * Remove the old qjni private APIs. * Remove the Android permission private APIs. * Remove runOnAndroidThread(). Pick-to: 6.2 Change-Id: I37ba8b4cb87a099f067e2e0b6744b8d01a0f9bbc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Android: Add runOnMainAndroidThread() under QNativeInterfaceAssam Boudjelthia2021-05-261-0/+3
| | | | | | | | | | | | This replaces QtAndroidPrivate::runOnAndroidThread{Sync} calls. This also now allows passing std::function<> that can return values, and not only an std::function<void()>. This adds some tests for this calls as well. Fixes: QTBUG-90501 Change-Id: I138d2aae64be17347f7ff712d8a86edb49ea8350 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add tests for QAndroidApplication's sdkVersion and activityAssam Boudjelthia2021-05-131-4/+4
| | | | | | | While at it, move tst_android under corelib/platform/android. Change-Id: Icf91cd75cb5e04d03fe6a81d52fba52a485ca41f Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Add hideSplashScreen() back temporarily to qjnihelpers_pAssam Boudjelthia2021-05-101-0/+7
| | | | | | | | This causes a build fail for androidextras, bring it back untill the full refactoring to use qtbase APIs is done. Change-Id: I3528c92d7c36818b105ae300ed1df9a7b281bb92 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Simplify setAndroidSdkVersion in qjnihelpersAssam Boudjelthia2021-05-081-15/+3
| | | | | Change-Id: Ib4695ffa1443a0b393d152a51a811f4afb163100 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Move hideSplashScreen() from qjnihelpers_p to QNativeInterfaceAssam Boudjelthia2021-05-081-7/+0
| | | | | | | | | | | | Hiding the splash screen require one JNI call instead of having to keep it as a global in qjnihelpers, and since it's not really easy to have a cross platform way for it it makes sense to have it under QNativeInterface. The alternative is probably removing it altogether since it's not useful often. Task-number: QTBUG-90500 Change-Id: I9b375c52afbf07e1ddd7957c1ec60af5c258f404 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Remove unused functions in qjnihelpersAssam Boudjelthia2021-05-081-37/+0
| | | | | | | | * Remove setNative{Activity,Service} and runOnUiThread functions which are not used anywhere, probably left overs. Change-Id: Ic7502dfd50d8eb4a9fa7abbe540a594a3614f14b Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Move JNI_OnLoad implementation to qjnihelpersAssam Boudjelthia2021-05-061-0/+36
| | | | | | | | To keep the Android implementation details as concise and close as possible. Change-Id: I8452e29ec4fc4b0a0c5e1861e159e7aea88c17b5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add new app permissions API under QCoreApplicationAssam Boudjelthia2021-05-051-1/+5
| | | | | | | | | | | | | | | | | | | | | The API allows users to request and check the status of various permissions. A predefined enum class of the common permission types on different platforms is used to allow requesting permission with a common code. Platform specific permissions are defined only on their relevant platform. For permissions that are not predefined, they can be requested via a string variant of this API. This adds the Android implementation only. [ChangeLog][QtCore] Add new API for handling app permissions with an initial implementation for Android. Task-number: QTBUG-90498 Change-Id: I3bc98c6ab2dceeea3ee8edec20a332ed8f56ad4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rename QJniEnvironment exceptionCheckAndClear to checkAndClearExceptionsAssam Boudjelthia2021-03-261-11/+11
| | | | | | | | | Address feedback from header view. Task-number: QTBUG-90211 Pick-to: 6.1 Change-Id: Iad2b609598b16f66fd6ab09484fe6e6899981263 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QJniObject and QJniEnvironment public APIAssam Boudjelthia2021-01-271-38/+36
| | | | | | | | | | | | | | | | | | | | As part of Qt 6 restructring for the extras modules, this change exposes the Jni APIs which are very important for Android platform. This patch adds the APIs QJniObject, QJniEnvironment, QJniExceptionCleaner based from private QtCore and QtAndroidExtras. The Jni interface is cross-platform which justifies the name, but currently, this API is used mainly for Android, and the naming comes generic without Android keyword to avoid any future limitation on supporting other platforms. [ChangeLog][QtCore] Add new QJniObject, QJniEnvironment and QJniExceptionCleaner APIs. Task-number: QTBUG-89482 Fixes: QTBUG-89633 Change-Id: I4382dd53a225375759b9d042f6035a4a9810572b Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Refactor QMutexLocker to be able to handle recursive mutexesLars Knoll2020-10-171-2/+2
| | | | | | | | Since we're going to split QMutex and QRecursiveMutex into separate classes, make sure QMutexLocker is prepared for that. Change-Id: Id5e9a955d1db7c8ee663dd3811ad6448dad0aeae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Android: rename Android's package name for Qt 6Assam Boudjelthia2020-10-031-2/+2
| | | | | | | | | | Rename Android package name org.qtproject.qt5.android to org.qtproject.qt.android to avoid inconsistency with Qt 6 name. Also, we include the major version number in the jar target. Task-number: QTBUG-86969 Change-Id: Ibb68947289be1079911b34ea157bf089cc52c47f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-291-3/+2
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Android: Fix hang in runOnAndroidThreadSync and requestPermissionsSyncBogDan Vatra2019-04-251-2/+14
| | | | | | | | | Keep spinning the main event loop if we can't acquire the semaphore, this way the Android UI thread can post events on it. Fixes: QTBUG-74076 Change-Id: Ia87e0535f94c67728176918ab928ff5ce8b00f8e Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io>
* Android: Fix possible crashBogDan Vatra2018-03-141-1/+1
| | | | | Change-Id: I3362dffe0f30196a2a1eabcffe6cb3b2d52a7785 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLars Knoll2018-01-021-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
| * Fix Android Service thread getting stuck in service startupHeikki Haveri2017-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change allows services using QAndroidService to function properly. A service using a plain QCoreApplication is still affected. The original code uses postfix decrement, causing an off-by-one error in reference counting, which, in turn, fails to properly release a semaphore. Fix by using deref() instead, which is also more readable, and consistent with the use of ref() elsewhere in the code. Task-number: QTBUG-64728 Change-Id: I99b59307638d619506c594f86de6d7d202d755f2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-7/+7
|/ | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Forward Service.onBind notification to QtBogDan Vatra2017-07-041-1/+33
| | | | | | | It is needed to implement Android Binder in Qt. Change-Id: I8f6f8ef778f97a444a1b16d6f62e211e188b65cc Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-191-7/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| * Android: Fix deadlock when calling requestPermissionBogDan Vatra2017-06-071-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The hang happend when using QtAndroidPrivate::requestPermissions before the QApplication::exec. Android UI calls "sendRequestPermissionsResult" which was blocking until the event is delivered, but the qt main loop is blocked and waits for the main surface to be created by the Android UI thread which is already blocked. With this patch sendRequestPermissionsResult won't block for the result to be delivered. Change-Id: I48ada65fe9ea63471ab46d8a9d839ba1b91d17b3 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
* | Android: Allow timeout to fade out splash screenMathias Hasselmann2017-03-011-3/+3
|/ | | | | | Change-Id: I7b24f4d402da7f74b4c983467008ff4c19fc3b1b Task-number: QTBUG-59200 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-161-24/+25
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/plugin/qlibrary_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
| * QJNIHelpers: unbreak runnables counterMarc Mutz2017-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding 0 each time will obviously not produce a new identifier each time... Also use static initialization for QBasicAtomicInt. A default-constructed static QBasicAtomicInt at function scope will be dynamically initialized. It will still be zero-initialized, but at least GCC adds guard variables for such objects. When using aggregate initialization, the guard disappears. Amends 265db5ad9bda9c984393c1e95fd27dcc4633ed1c. Change-Id: Ia71290cf26c486dcbcc74381f12cd0c4712d6019 Reviewed-by: David Faure <david.faure@kdab.com>
| * QJNIHelpers: make mutexes staticMarc Mutz2017-02-151-2/+2
| | | | | | | | | | | | | | Amends 265db5ad9bda9c984393c1e95fd27dcc4633ed1c. Change-Id: I707bb88285531ee9f82efec46901871d53413eb3 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * Fix UB (data race) in QtAndroidPrivate::requestPermissionsSync()Marc Mutz2017-02-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the QSemaphore::tryAcquire() call times out, we mustn't touch *res, because there was no happens-before relation established between *res = result in the lambda and our returning *res; Fix by returning a default-constructed hash in that case. Add a strategic std::move(). The same problem exists in runOnAndroidThreadSync(), but I have no idea how to solve it, because there the shared object is the runnable itself. Change-Id: I9a2c431144c169fbd545763555d96153143a11bf Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * QJNIHelper: fix a potential race in sendRequestPermissionsResult()Marc Mutz2017-02-151-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code obtained an iterator into a QHash under mutex protection, then dropped the lock, dereferenced the iterator several times and only retook the lock to erase the element from the QHash. This is very smelly. QHash provides no official iterator validity guarantees, and the container isn't const, either (which would imply thread-safety). In particular, the dereference into the container outside the critical section is cause for concerns. Simplify the code, removing any doubts about its race-freedom, by taking the payload item out of the hash before dropping the lock, and using only the local strong reference in the remainder of the function. The only other references to g_pendingPermissionRequests are insertions with unique-by-construction keys in QtAndroidPrivate's requestPermissions(), so there was no reason to keep the item in the hash for the whole duration of the sendRequestPermissionsResult() call. Change-Id: I39fe0803b13b3046d1f0fd9c8e96c531406d57da Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * Enable QtAndroid::runOnAndroidThread in a ServiceHeikki Haveri2017-02-151-1/+1
| | | | | | | | | | Change-Id: I214f5dc70c52011a5e1712ea70f97f8b564fb664 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * QJNIHelper: clean up atomic int and mutex handlingMarc Mutz2017-02-141-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Do not use Q_GLOBAL_STATIC to hold QAtomicInt or QMutex, use file-static QBasicAtomicInt and QBasicMutex instead. They are zero-initialized PODs. 2. Use only QMutexLocker to lock mutexes. Also wrap the atomic counter into a next...() function, as done elsewhere. Change-Id: I4b14ac0de9d4cb6780b1f1372c2b5fc88e918e4c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Android: De-duplicate vtables of exported private classesMarc Mutz2017-02-161-0/+12
|/ | | | | | | | | | | | | | | | | | | | By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info structures for the class are pinned to a single TU. This prevents false-negative dynamic_cast and catch evaluation. Since the classes are already exported, users of these classes are unaffected by the change, and since it's private API, we don't need to avoid adding code to the out-of-line destructor until Qt 6. While at it, de-inline also the empty default implementations of virtual (non-dtor) functions. Task-number: QTBUG-45582 Change-Id: I3e6f37eab1dee0db445f6c13638a43ca3bf6ac62 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Say hello to Android 6+ permissions modelBogDan Vatra2016-09-161-1/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | This API was introduced by Android v23 and is used in connection with the new permission request system. From Android v23 onwards, some permissions such as Location permissions cannot only be granted via Android's Manifest files. An additional runtime check/request system was introduced which forces applications to prompt the user the first time a privileged function is called. Such user prompt responses are returned to the current application via the Activity.onRequestPermissionsResult(..) callback. This change add Qt API to nicely check & request permissions. For now this is private API which can be used to fix permission problems in other Qt compontents. Later Qt versions will introduce a public API to QtAndroidExtras. [ChangeLog][QtCore][Android] Introduced a mechanism to forward permission related callbacks on Activity objects to interested parties. Task-number: QTBUG-55035 Task-number: QTBUG-50759 Change-Id: I64ee748d741b39e35c4713ed9fdd15dd1d96dc56 Reviewed-by: Christian Stromme <christian.stromme@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add QtAndroidPrivate::context()Alex Blasche2016-08-031-0/+10
| | | | | | | | This simplifies the retrieval of the correct Context object. Task-number: QTBUG-55102 Change-Id: I303bc5393a7900ceb4bde36e711938f3f49075c1 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Perfect (almost) Qt on Android splash screen.BogDan Vatra2016-02-241-1/+7
| | | | | | | | | | | | | There is no need to show the splash image immediately when the application starts, because it will be removed shortly in QtActivityDelegate.java, therefore show the splash in QtActivityDelegate.java. This patch also adds a new option to AndroidManifest.xml which keeps the splash screen visible until user to decides to hide it, by using the QtAndroid::hideSplashScreen() function. Change-Id: I8a29a5a757d626c4c9d6a2748a60ca3091ebf82d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Say hello to Android ServicesBogDan Vatra2016-02-171-2/+53
| | | | | | | | | | | | | | This changeset enables running a QCoreApplication from within an Android Service. The Android Application running can now have a QtActivity or a QtService, but having both in the same process is not supported. This patch was based on Cory Slep's patch [ChangeLog][Android] Qt can now be used to easily create Android Services. Task-number: QTBUG-37221 Change-Id: I0fd693daaa85b991940ffe9cc41c483022677199 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Android: Add runOnAndroidThreadSyncBogDan Vatra2016-02-041-0/+11
| | | | | | | This is a convenient function which waits (timoutMS) for the runnable to be executed. Change-Id: I2c0f262d3795c29961e8182b7ffc35a2c6f8a1f6 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>