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)
160#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
161QFuture<QVariant> QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
162 const std::function<
QVariant()> &runnable,
165 auto promise = std::make_shared<QPromise<QVariant>>();
166 QFuture<QVariant>
future = promise->future();
178 QFutureWatcher<QVariant>
watcher;
199#ifdef __cpp_aggregate_paren_init
200 g_pendingRunnables->emplace_back(runnable, std::move(promise));
202 g_pendingRunnables->push_back({runnable, std::move(promise)});
207 "runPendingCppRunnablesOnAndroidThread",
213static void runPendingCppRunnables(JNIEnv *, jobject )
218 if (g_pendingRunnables->empty())
221 PendingRunnable
r = std::move(g_pendingRunnables->front());
222 g_pendingRunnables->pop_front();
226 if (!
r.promise->isCanceled())
227 r.promise->addResult(
r.function());
235#if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
236 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
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
bool singleShot
whether the timer is a single-shot timer
Combined button and popup list for selecting options.
Q_CORE_EXPORT jint androidSdkVersion()
bool registerNativeInterfaceNatives(QJniEnvironment &env)
Posts the function runnable to the Android thread.
Q_CORE_EXPORT QtJniTypes::Context context()
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