summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-06-22 15:48:48 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2017-06-23 19:48:43 +0000
commit2aa2a2c7e893a456be4fffdc8ae96810c3517e9a (patch)
treeba0cd7f551e0257bf16cf166aa4a947873360985
parentaae4768483839a3189bd32f7d44a86905ecb3e5b (diff)
Adjust pingpong example to Android UUID SDP discovery bug
Task-number: QTBUG-61392 Change-Id: Ie2173b57093db9285e8fc90dbec66f81b002f7c6 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--examples/bluetooth/pingpong/pingpong.cpp11
-rw-r--r--examples/bluetooth/pingpong/pingpong.h3
-rw-r--r--examples/bluetooth/pingpong/pingpong.pro1
3 files changed, 14 insertions, 1 deletions
diff --git a/examples/bluetooth/pingpong/pingpong.cpp b/examples/bluetooth/pingpong/pingpong.cpp
index ab6ba8c7..58d5ff2f 100644
--- a/examples/bluetooth/pingpong/pingpong.cpp
+++ b/examples/bluetooth/pingpong/pingpong.cpp
@@ -40,6 +40,9 @@
#include "pingpong.h"
#include <QDebug>
+#ifdef Q_OS_ANDROID
+#include <QtAndroid>
+#endif
PingPong::PingPong():
m_serverInfo(0), socket(0), discoveryAgent(0), interval(5), m_resultLeft(0), m_resultRight(0),
@@ -253,8 +256,16 @@ void PingPong::startClient()
connect(discoveryAgent, SIGNAL(finished()), this, SLOT(done()));
connect(discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
this, SLOT(serviceScanError(QBluetoothServiceDiscoveryAgent::Error)));
+#ifdef Q_OS_ANDROID //see QTBUG-61392
+ if (QtAndroid::androidSdkVersion() >= 23)
+ discoveryAgent->setUuidFilter(QBluetoothUuid(androidUuid));
+ else
+ discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid));
+#else
discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid));
+#endif
discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+
//! [Searching for the service]
setMessage(QStringLiteral("Starting server discovery. You are the right player"));
// m_role is set to 2 if it is a client
diff --git a/examples/bluetooth/pingpong/pingpong.h b/examples/bluetooth/pingpong/pingpong.h
index 650cd597..21c9ef1c 100644
--- a/examples/bluetooth/pingpong/pingpong.h
+++ b/examples/bluetooth/pingpong/pingpong.h
@@ -48,7 +48,8 @@
#include <qbluetoothlocaldevice.h>
#include <qbluetoothservicediscoveryagent.h>
-static const QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9"));
+static QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9"));
+static QString androidUuid(QStringLiteral("c9e96402-0102-cf9c-274b-701a950fe1e8"));
class PingPong: public QObject
{
diff --git a/examples/bluetooth/pingpong/pingpong.pro b/examples/bluetooth/pingpong/pingpong.pro
index 07675f27..aa79212e 100644
--- a/examples/bluetooth/pingpong/pingpong.pro
+++ b/examples/bluetooth/pingpong/pingpong.pro
@@ -2,6 +2,7 @@ TEMPLATE = app
TARGET = pingpong
QT += quick bluetooth
+android: QT += androidextras
# Input
SOURCES += main.cpp \