diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-06-21 09:20:56 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-06-22 12:49:36 +0000 |
commit | aae4768483839a3189bd32f7d44a86905ecb3e5b (patch) | |
tree | a92c609795aaac07655bf6ac7dac32fae930839f /examples/bluetooth | |
parent | 71f22ac56c744ed71ccc26423a9c7a08fc4eb4e6 (diff) |
Adjust qml chat example to workaround required to Android SDP bug
Task-number: QTBUG-61542
Task-number: QTBUG-61392
Change-Id: Iff5c827d7ebb96dd29bc80f444d03804eddf405b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'examples/bluetooth')
-rw-r--r-- | examples/bluetooth/chat/chat.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/chat/chat.qml | 4 | ||||
-rw-r--r-- | examples/bluetooth/chat/qmlchat.cpp | 18 |
3 files changed, 21 insertions, 2 deletions
diff --git a/examples/bluetooth/chat/chat.pro b/examples/bluetooth/chat/chat.pro index 7bc5c8bd..36d815f9 100644 --- a/examples/bluetooth/chat/chat.pro +++ b/examples/bluetooth/chat/chat.pro @@ -1,4 +1,5 @@ QT = core bluetooth quick +android: QT += androidextras #see QTBUG-61392 SOURCES += qmlchat.cpp TARGET = qml_chat diff --git a/examples/bluetooth/chat/chat.qml b/examples/bluetooth/chat/chat.qml index 06f2fc49..eee29789 100644 --- a/examples/bluetooth/chat/chat.qml +++ b/examples/bluetooth/chat/chat.qml @@ -53,7 +53,7 @@ Item { BluetoothDiscoveryModel { id: btModel running: true - discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery + discoveryMode: BluetoothDiscoveryModel.FullServiceDiscovery //! [BtDiscoveryModel-1] onRunningChanged : { if (!btModel.running && top.state == "begin" && !serviceFound) { @@ -81,7 +81,7 @@ Item { } //! [BtDiscoveryModel-2] //! [BtDiscoveryModel-3] - uuidFilter: "e8e10f95-1a70-4b27-9ccf-02010264e9c8" + uuidFilter: targetUuid //e8e10f95-1a70-4b27-9ccf-02010264e9c8 } //! [BtDiscoveryModel-3] diff --git a/examples/bluetooth/chat/qmlchat.cpp b/examples/bluetooth/chat/qmlchat.cpp index 8cd90bda..c6ff6341 100644 --- a/examples/bluetooth/chat/qmlchat.cpp +++ b/examples/bluetooth/chat/qmlchat.cpp @@ -44,9 +44,14 @@ #include <QtQml/QQmlContext> #include <QDebug> #include <QBluetoothLocalDevice> +#include <QtCore/QLoggingCategory> +#ifdef Q_OS_ANDROID +#include <QtAndroidExtras/QtAndroid> +#endif int main(int argc, char *argv[]) { + //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QGuiApplication application(argc, argv); QList<QBluetoothHostInfo> infos = QBluetoothLocalDevice::allDevices(); @@ -56,6 +61,19 @@ int main(int argc, char *argv[]) const QString mainQmlApp = QLatin1String("qrc:/chat.qml"); QQuickView view; + +#ifdef Q_OS_ANDROID + //workaround for Android's SDP discovery bug (see QTBUG-61392) + QString uuid; + if (QtAndroid::androidSdkVersion() >= 23) + uuid = QStringLiteral("c8e96402-0102-cf9c-274b-701a950fe1e8"); + else + uuid = QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8"); +#else + const QString uuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8")); +#endif + + view.engine()->rootContext()->setContextProperty(QStringLiteral("targetUuid"), uuid); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QQuickView::SizeRootObjectToView); // Qt.quit() called in embedded .qml by default only emits |