summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_android.cpp6
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp50
-rw-r--r--src/bluetooth/qbluetoothsocket_android_p.h2
3 files changed, 33 insertions, 25 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index ddc53421..e607a27e 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
@@ -47,6 +47,7 @@
#include <QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include "qbluetoothservicediscoveryagent_p.h"
+#include "qbluetoothsocket_android_p.h"
#include "android/servicediscoverybroadcastreceiver_p.h"
#include "android/localdevicebroadcastreceiver_p.h"
@@ -449,8 +450,11 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB
//Check if the service is in the uuidFilter
if (!uuidFilter.isEmpty()) {
bool match = uuidFilter.contains(serviceInfo.serviceUuid());
- for (const auto &uuid : qAsConst(uuidFilter))
+ match |= uuidFilter.contains(QBluetoothSocketPrivateAndroid::reverseUuid(serviceInfo.serviceUuid()));
+ for (const auto &uuid : qAsConst(uuidFilter)) {
match |= serviceInfo.serviceClassUuids().contains(uuid);
+ match |= serviceInfo.serviceClassUuids().contains(QBluetoothSocketPrivateAndroid::reverseUuid(uuid));
+ }
if (!match)
continue;
diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp
index d7f17d17..46bd4a23 100644
--- a/src/bluetooth/qbluetoothsocket_android.cpp
+++ b/src/bluetooth/qbluetoothsocket_android.cpp
@@ -182,30 +182,6 @@ private:
QPointer<SocketConnectWorker> workerPointer;
};
-/*
- * This function is part of a workaround for QTBUG-61392
- *
- * Returns null uuid if the given \a serviceUuid is not a uuid
- * derived from the Bluetooth base uuid.
- */
-static QBluetoothUuid reverseUuid(const QBluetoothUuid &serviceUuid)
-{
- if (serviceUuid.isNull())
- return QBluetoothUuid();
-
- bool isBaseUuid = false;
- serviceUuid.toUInt32(&isBaseUuid);
- if (isBaseUuid)
- return serviceUuid;
-
- const quint128 original = serviceUuid.toUInt128();
- quint128 reversed;
- for (int i = 0; i < 16; i++)
- reversed.data[15-i] = original.data[i];
-
- return QBluetoothUuid(reversed);
-}
-
QBluetoothSocketPrivateAndroid::QBluetoothSocketPrivateAndroid()
:
inputThread(0)
@@ -942,6 +918,32 @@ qint64 QBluetoothSocketPrivateAndroid::bytesToWrite() const
return 0; // nothing because always unbuffered
}
+/*
+ * This function is part of a workaround for QTBUG-61392
+ *
+ * Returns null uuid if the given \a serviceUuid is not a uuid
+ * derived from the Bluetooth base uuid.
+ */
+QBluetoothUuid QBluetoothSocketPrivateAndroid::reverseUuid(const QBluetoothUuid &serviceUuid)
+{
+ if (QtAndroid::androidSdkVersion() < 23)
+ return serviceUuid;
+
+ if (serviceUuid.isNull())
+ return QBluetoothUuid();
+
+ bool isBaseUuid = false;
+ serviceUuid.toUInt32(&isBaseUuid);
+ if (isBaseUuid)
+ return serviceUuid;
+
+ const quint128 original = serviceUuid.toUInt128();
+ quint128 reversed;
+ for (int i = 0; i < 16; i++)
+ reversed.data[15-i] = original.data[i];
+ return QBluetoothUuid{reversed};
+}
+
bool QBluetoothSocketPrivateAndroid::canReadLine() const
{
// We cannot access buffer directly as it is part of different thread
diff --git a/src/bluetooth/qbluetoothsocket_android_p.h b/src/bluetooth/qbluetoothsocket_android_p.h
index 7bf42e32..042e1bcd 100644
--- a/src/bluetooth/qbluetoothsocket_android_p.h
+++ b/src/bluetooth/qbluetoothsocket_android_p.h
@@ -112,6 +112,8 @@ public:
bool canReadLine() const override;
qint64 bytesToWrite() const override;
+ static QBluetoothUuid reverseUuid(const QBluetoothUuid &serviceUuid);
+
QAndroidJniObject adapter;
QAndroidJniObject socketObject;
QAndroidJniObject remoteDevice;