From 97dc04e0d74687b4cafab3676d3582f758a0a4cc Mon Sep 17 00:00:00 2001
From: Alex Blasche <alexander.blasche@qt.io>
Date: Fri, 12 Oct 2018 13:30:48 +0200
Subject: [PATCH] Fix SDP BrowseGroupList entry

A BrowseGroupList is defined as sequence in which each element is a UUID
that represents a browse group to which the service record belongs.
Except for the QBluetoothServer::listen() implementation every other
implementation did not use the sequence pattern. This patch unifies
all BrowseGroupList entries through QtBluetooth and its examples/tests.

Change-Id: I37640ae0500c557d79350359883abc6a66a46346
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
---
 src/bluetooth/qbluetoothserver_osx.mm                        | 5 +++--
 src/bluetooth/qbluetoothservicediscoveryagent_android.cpp    | 5 +++--
 src/imports/bluetooth/qdeclarativebluetoothservice.cpp       | 5 +++--
 .../tst_qbluetoothservicediscoveryagent.cpp                  | 5 +++--
 tests/bttestui/btlocaldevice.cpp                             | 5 +++--
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_osx.mm
index a6768432..eefaf4da 100644
--- a/src/bluetooth/qbluetoothserver_osx.mm
+++ b/src/bluetooth/qbluetoothserver_osx.mm
@@ -377,8 +377,9 @@ QBluetoothServiceInfo QBluetoothServer::listen(const QBluetoothUuid &uuid, const
 
     QBluetoothServiceInfo serviceInfo;
     serviceInfo.setAttribute(QSInfo::ServiceName, serviceName);
-    serviceInfo.setAttribute(QSInfo::BrowseGroupList,
-                             QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+    QBluetoothServiceInfo::Sequence publicBrowse;
+    publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+    serviceInfo.setAttribute(QSInfo::BrowseGroupList, publicBrowse);
 
     QSInfo::Sequence profileSequence;
     QSInfo::Sequence classId;
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index f8201c86..7ab1f50c 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
@@ -410,8 +410,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB
         }
 
         serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
-        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
-                                 QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        QBluetoothServiceInfo::Sequence publicBrowse;
+        publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
 
         if (!customUuids.contains(i)) {
             //if we don't have custom uuid use it as class id as well
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
index 3c176752..b0d0db60 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
@@ -306,8 +306,9 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
 
     //qDebug() << "name/uuid" << d->m_name << d->m_uuid << d->m_port;
 
-    d->m_service->setAttribute(QBluetoothServiceInfo::BrowseGroupList,
-                               QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+    QBluetoothServiceInfo::Sequence publicBrowse;
+    publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+    d->m_service->setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
 
     QBluetoothServiceInfo::Sequence protocolDescriptorList;
     QBluetoothServiceInfo::Sequence protocol;
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index 9bac6791..94a065bc 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -286,8 +286,9 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryAdapters()
         server.listen(addresses[0]);
         QBluetoothServiceInfo serviceInfo;
         serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, "serviceName");
-        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
-                                 QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        QBluetoothServiceInfo::Sequence publicBrowse;
+        publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
 
         QBluetoothServiceInfo::Sequence profileSequence;
         QBluetoothServiceInfo::Sequence classId;
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp
index d7590b70..07edbe0c 100644
--- a/tests/bttestui/btlocaldevice.cpp
+++ b/tests/bttestui/btlocaldevice.cpp
@@ -600,8 +600,9 @@ void BtLocalDevice::serverListenPort()
 
 
         // Service Discoverability
-        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
-                                 QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        QBluetoothServiceInfo::Sequence browseSequence;
+        browseSequence << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+        serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, browseSequence);
 
         // Protocol descriptor list
         QBluetoothServiceInfo::Sequence protocolDescriptorList;
-- 
GitLab