From 72a48c7d108e1f3faaab0a03c6d2a6ead16d2bcc Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 15 Aug 2018 12:37:58 +0200 Subject: Android: Fix QBluetoothServiceDiscoveryAgent::uuidFilter() behavior Task-number: QTBUG-69700 Change-Id: Ib8082156f81949926380e4e296d91c8dfc01b231 Reviewed-by: Oliver Wolff --- src/bluetooth/qbluetoothservicediscoveryagent_android.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent_android.cpp') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index 51db091e..0d2aff2c 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -393,10 +393,6 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB serviceInfo.setServiceUuid(uuids.at(i)); } - //Check if the UUID is in the uuidFilter - if (!uuidFilter.isEmpty() && !uuidFilter.contains(serviceInfo.serviceUuid())) - continue; - serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList); serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); @@ -411,6 +407,16 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB serviceInfo.setServiceName(QBluetoothUuid::serviceClassToString(clsId)); } + //Check if the service is in the uuidFilter + if (!uuidFilter.isEmpty()) { + bool match = uuidFilter.contains(serviceInfo.serviceUuid()); + for (const auto &uuid : qAsConst(uuidFilter)) + match |= serviceInfo.serviceClassUuids().contains(uuid); + + if (!match) + continue; + } + //don't include the service if we already discovered it before if (!isDuplicatedService(serviceInfo)) { discoveredServices << serviceInfo; -- cgit v1.2.3