From aae4768483839a3189bd32f7d44a86905ecb3e5b Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 21 Jun 2017 09:20:56 +0200 Subject: 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 --- examples/bluetooth/chat/chat.pro | 1 + examples/bluetooth/chat/chat.qml | 4 ++-- 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 #include #include +#include +#ifdef Q_OS_ANDROID +#include +#endif int main(int argc, char *argv[]) { + //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QGuiApplication application(argc, argv); QList 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 -- cgit v1.2.3