diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-05-26 15:49:12 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-03 12:19:24 +0200 |
commit | bf1a06f6aaedf7709947eb284226348fb0385cc0 (patch) | |
tree | 84d7e38df6d61c11f82f80fa86693e00c35de3b9 /src/bluetooth | |
parent | b28dbaf82f1140420f60d9f26a637f365fac9bbf (diff) | |
download | qtconnectivity-bf1a06f6aaedf7709947eb284226348fb0385cc0.tar.gz |
Avoid empty service names
Bluez doesn't seem to know the service class uuid 0x1200 which seems
common on BB10 devices. Ensure that we set a name if Bluez did not
provide a name. This was made possible by the recent addition of
QBluetoothUuid::serviceClassToString(..).
[ChangeLog][QtBluetooth][QBluetoothServiceDiscoveryAgent] Fixed
cases where Bluez doesn't provide service names for given Bluetooth
service class uuid.
Change-Id: Ife56ab878f70ca6226e907f59972368c79318bec
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/bluetooth')
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp index cd5562ac..177ce63e 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp @@ -458,7 +458,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC qCDebug(QT_BT_BLUEZ) << "Parsing xml" << discoveredDevices.at(0).address().toString() << discoveredDevices.count() << map.count(); foreach (const QString &record, reply.value()) { - const QBluetoothServiceInfo serviceInfo = parseServiceXml(record); + QBluetoothServiceInfo serviceInfo = parseServiceXml(record); if (!serviceInfo.isValid()) continue; @@ -467,6 +467,20 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC // search pattern during DiscoverServices() call Q_Q(QBluetoothServiceDiscoveryAgent); + // Some service uuids are unknown to Bluez. In such cases we fall back + // to our own naming resolution. + if (serviceInfo.serviceName().isEmpty() + && !serviceInfo.serviceClassUuids().isEmpty()) { + foreach (const QBluetoothUuid &classUuid, serviceInfo.serviceClassUuids()) { + bool ok = false; + QBluetoothUuid::ServiceClassUuid clsId + = static_cast<QBluetoothUuid::ServiceClassUuid>(classUuid.toUInt16(&ok)); + if (ok) { + serviceInfo.setServiceName(QBluetoothUuid::serviceClassToString(clsId)); + break; + } + } + } if (!isDuplicatedService(serviceInfo)) { discoveredServices.append(serviceInfo); |