diff options
author | BogDan Vatra <bogdan@kde.org> | 2019-04-04 14:26:04 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2019-04-05 06:37:39 +0000 |
commit | c161203b5dd91ace4b14d46542c49115e8de8d92 (patch) | |
tree | f1079cf99cf6907835b482606ff742116cd55a5f /src/bluetooth/qbluetoothsocket_android.cpp | |
parent | 38bb5bae0a05407ec180a140c00231a39ef23cd2 (diff) |
Check the reverted UUID when filtering
Change-Id: Idb12d3bb116d6c5b34f1ca145f473b118b58d5ee
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothsocket_android.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothsocket_android.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
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 |