4#include <QtCore/qcoreapplication_platform.h>
6#include <QtCore/private/qnativeinterface_p.h>
7#include <QtCore/private/qjnihelpers_p.h>
8#include <QtCore/qjniobject.h>
9#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
10#include <QtCore/qfuture.h>
11#include <QtCore/qfuturewatcher.h>
12#include <QtCore/qpromise.h>
13#include <QtCore/qtimer.h>
14#include <QtCore/qthreadpool.h>
21#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
24struct PendingRunnable {
26 std::shared_ptr<QPromise<QVariant>> promise;
29using PendingRunnables = std::deque<PendingRunnable>;
31Q_CONSTINIT
static QBasicMutex g_pendingRunnablesMutex;
56QtJniTypes::Context QNativeInterface::QAndroidApplication::context()
69bool QNativeInterface::QAndroidApplication::isActivityContext()
81int QNativeInterface::QAndroidApplication::sdkVersion()
95void QNativeInterface::QAndroidApplication::hideSplashScreen(
int duration)
97 QJniObject::callStaticMethod<void>(
"org/qtproject/qt/android/QtNative",
98 "hideSplashScreen",
"(I)V", duration);
161#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
163 const std::function<
QVariant()> &runnable,
166 auto promise = std::make_shared<QPromise<QVariant>>();
200#ifdef __cpp_aggregate_paren_init
201 g_pendingRunnables->emplace_back(runnable, std::move(promise));
203 g_pendingRunnables->push_back({runnable, std::move(promise)});
208 "runPendingCppRunnablesOnAndroidThread",
214static void runPendingCppRunnables(JNIEnv *, jobject )
219 if (g_pendingRunnables->empty())
222 PendingRunnable
r = std::move(g_pendingRunnables->front());
223 g_pendingRunnables->pop_front();
227 if (!
r.promise->isCanceled())
228 r.promise->addResult(
r.function());
236#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
237 const JNINativeMethod
methods = {
"runPendingCppRunnables",
"()V", (
void *)runPendingCppRunnables};
static JNINativeMethod methods[]
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void quit()
Tells the event loop to exit normally.
Native interface to a core application on Android.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void reserveThread()
Reserves one thread, disregarding activeThreadCount() and maxThreadCount().
void start(QRunnable *runnable, int priority=0)
Reserves a thread and uses it to run runnable, unless this thread will make the current thread count ...
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
void releaseThread()
Releases a thread previously reserved by a call to reserveThread().
bool singleShot
whether the timer is a single-shot timer
Combined button and popup list for selecting options.
Q_CORE_EXPORT jint androidSdkVersion()
Q_CORE_EXPORT QtJniTypes::Context context()
bool registerNativeInterfaceNatives()
Posts the function runnable to the Android thread.
Q_CORE_EXPORT QtJniTypes::Activity activity()
static const char qtNativeClassName[]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define QT_DEFINE_NATIVE_INTERFACE(...)
GLbitfield GLuint64 timeout
[4]
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
QFuture< void > future
[5]
QFutureWatcher< int > watcher