diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | src/androidextras/android/qandroidservice.cpp | 25 | ||||
-rw-r--r-- | src/androidextras/android/qandroidservice.h | 7 | ||||
-rw-r--r-- | src/androidextras/androidextras.pro | 2 | ||||
-rw-r--r-- | src/jar/bundledjar.pro | 3 | ||||
-rw-r--r-- | src/jar/distributedjar.pro | 2 | ||||
-rw-r--r-- | src/jar/jar.pri | 14 | ||||
-rw-r--r-- | src/jar/jar.pro | 19 |
8 files changed, 45 insertions, 29 deletions
diff --git a/.qmake.conf b/.qmake.conf index 52f1d69..7dccd20 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.10.1 +MODULE_VERSION = 5.11.0 diff --git a/src/androidextras/android/qandroidservice.cpp b/src/androidextras/android/qandroidservice.cpp index 272c829..227787a 100644 --- a/src/androidextras/android/qandroidservice.cpp +++ b/src/androidextras/android/qandroidservice.cpp @@ -54,8 +54,9 @@ QT_BEGIN_NAMESPACE class QAndroidServicePrivate : public QObject, public QtAndroidPrivate::OnBindListener { public: - QAndroidServicePrivate(QAndroidService *service) + QAndroidServicePrivate(QAndroidService *service, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder = {}) : m_service(service) + , m_binder(binder) { QTimer::singleShot(0,this, [this]{ QtAndroidPrivate::setOnBindListener(this);}); } @@ -74,7 +75,8 @@ public: // OnBindListener interface jobject onBind(jobject intent) override { - auto binder = m_service->onBind(QAndroidIntent(intent)); + auto qai = QAndroidIntent(intent); + auto binder = m_binder ? m_binder(qai) : m_service->onBind(qai); if (binder) { { QMutexLocker lock(&m_bindersMutex); @@ -93,8 +95,9 @@ private: m_binders.remove(obj); } -private: - QAndroidService *m_service; +public: + QAndroidService *m_service = nullptr; + std::function<QAndroidBinder *(const QAndroidIntent &)> m_binder; QMutex m_bindersMutex; QSet<QAndroidBinder*> m_binders; }; @@ -117,7 +120,19 @@ private: */ QAndroidService::QAndroidService(int &argc, char **argv, int flags) : QCoreApplication (argc, argv, QtAndroidPrivate::acuqireServiceSetup(flags)) - , d(new QAndroidServicePrivate(this)) + , d(new QAndroidServicePrivate{this}) +{ +} + +/*! + Creates a new Android Service + + \a binder is used to create a binder each when is needed + \sa QCoreApplication + */ +QAndroidService::QAndroidService(int &argc, char **argv, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder, int flags) + : QCoreApplication (argc, argv, QtAndroidPrivate::acuqireServiceSetup(flags)) + , d(new QAndroidServicePrivate{this, binder}) { } diff --git a/src/androidextras/android/qandroidservice.h b/src/androidextras/android/qandroidservice.h index 72e47a4..8c0855c 100644 --- a/src/androidextras/android/qandroidservice.h +++ b/src/androidextras/android/qandroidservice.h @@ -43,6 +43,7 @@ #include <QtAndroidExtras/qandroidextrasglobal.h> #include <QCoreApplication> #include <QSharedPointer> +#include <functional> QT_BEGIN_NAMESPACE class QAndroidServicePrivate; @@ -56,6 +57,12 @@ public: , int flags = ApplicationFlags #endif ); + QAndroidService(int &argc, char **argv, + const std::function<QAndroidBinder*(const QAndroidIntent &intent)> & binder +#ifndef Q_QDOC + , int flags = ApplicationFlags +#endif + ); virtual ~QAndroidService(); virtual QAndroidBinder* onBind(const QAndroidIntent &intent); diff --git a/src/androidextras/androidextras.pro b/src/androidextras/androidextras.pro index 584c82e..132643d 100644 --- a/src/androidextras/androidextras.pro +++ b/src/androidextras/androidextras.pro @@ -9,8 +9,6 @@ include(jni/jni.pri) include(android/android.pri) ANDROID_BUNDLED_JAR_DEPENDENCIES = \ - jar/QtAndroidExtras-bundled.jar -ANDROID_JAR_DEPENDENCIES = \ jar/QtAndroidExtras.jar load(qt_module) diff --git a/src/jar/bundledjar.pro b/src/jar/bundledjar.pro deleted file mode 100644 index 9456e1c..0000000 --- a/src/jar/bundledjar.pro +++ /dev/null @@ -1,3 +0,0 @@ -TARGET = QtAndroidExtras-bundled -CONFIG += bundled_jar_file -include(jar.pri) diff --git a/src/jar/distributedjar.pro b/src/jar/distributedjar.pro deleted file mode 100644 index 714916b..0000000 --- a/src/jar/distributedjar.pro +++ /dev/null @@ -1,2 +0,0 @@ -TARGET = QtAndroidExtras -include(jar.pri) diff --git a/src/jar/jar.pri b/src/jar/jar.pri deleted file mode 100644 index 8ea4342..0000000 --- a/src/jar/jar.pri +++ /dev/null @@ -1,14 +0,0 @@ -load(qt_build_paths) -CONFIG += java -DESTDIR = $$MODULE_BASE_OUTDIR/jar - -JAVACLASSPATH += $$PWD/src - -JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/extras/QtAndroidBinder.java \ - $$PWD/src/org/qtproject/qt5/android/extras/QtAndroidServiceConnection.java \ - $$PWD/src/org/qtproject/qt5/android/extras/QtNative.java -# install -target.path = $$[QT_INSTALL_PREFIX]/jar -INSTALLS += target - -OTHER_FILES += $$JAVASOURCES diff --git a/src/jar/jar.pro b/src/jar/jar.pro index 6a4fcd3..a30922d 100644 --- a/src/jar/jar.pro +++ b/src/jar/jar.pro @@ -1,3 +1,18 @@ -TEMPLATE=subdirs -SUBDIRS += distributedjar.pro bundledjar.pro +TARGET = QtAndroidExtras +load(qt_build_paths) +CONFIG += java + +DESTDIR = $$MODULE_BASE_OUTDIR/jar + +JAVACLASSPATH += $$PWD/src + +JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/extras/QtAndroidBinder.java \ + $$PWD/src/org/qtproject/qt5/android/extras/QtAndroidServiceConnection.java \ + $$PWD/src/org/qtproject/qt5/android/extras/QtNative.java + +# install +target.path = $$[QT_INSTALL_PREFIX]/jar +INSTALLS += target + +OTHER_FILES += $$JAVASOURCES |