diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-04-11 13:14:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-15 14:26:46 +0200 |
commit | 14532147e29dd2337ee024eeb8e0af7ba9964841 (patch) | |
tree | a9b3c77998bffa689a9eb231d323c8f71f8dcbe0 | |
parent | d6f4ada86a20b1e25e61dae3d764fc4a35c3b3d9 (diff) | |
download | qtconnectivity-14532147e29dd2337ee024eeb8e0af7ba9964841.tar.gz |
Do not always filter Serial Port profiles out anymore on Android
1.) If we find a custom and SPP uuid we create only on service
using custom uuid as service uuid and SPP as service class uuid.
THis is the recommended way. Any remote service should really
advertise a custom uuid. Unfortunately this is not always the
case on some embedded devices. Hence we need to cover the cases
below.
2.) If we find a custom uuid only we create a service which uses
the custom uuid as service uuid but we do not set a service class.
3.) If we find a SPP uuid only, we create a service which uses SPP
as service uuid and as service class uuid. This is no problem as
Android's connectToRfcommService() call explicitly permits an SPP
uuid as connection parameter.
4.) We find none of the above the problem doesn't exist in the
first place and no service was found.
Task-number: QTBUG-38140
Change-Id: I2e9080f65b98db23782264ef9e62a410ab9f91f1
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
-rw-r--r-- | src/bluetooth/qbluetoothservicediscoveryagent_android.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index 2e55d40e..4a8b62e7 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -416,7 +416,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB } for (int i = 0; i < uuids.count(); i++) { - if (i == sppIndex) //skip SPP service class id + if (i == sppIndex && !customUuids.isEmpty()) continue; QBluetoothServiceInfo serviceInfo; @@ -444,6 +444,21 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Serial Port Profile")); serviceInfo.setServiceUuid(uuids.at(i)); + } else if (sppIndex == i && customUuids.isEmpty()) { + //set rfcomm protocol + QBluetoothServiceInfo::Sequence protocol; + protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) + << QVariant::fromValue(0); + protocolDescriptorList.append(QVariant::fromValue(protocol)); + + QBluetoothServiceInfo::Sequence classId; + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, + classId); + + //also we need to set the custom uuid to the SPP uuid + //otherwise QBluetoothSocket::connectToService() would fail due to a missing service uuid + serviceInfo.setServiceUuid(uuids.at(i)); } else if (customUuids.contains(i)) { //custom uuid but no serial port serviceInfo.setServiceUuid(uuids.at(i)); |