diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-06-06 14:54:40 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-06-07 09:31:52 +0000 |
commit | 1125e32c564158ac9c6cbd22308a75de30e21484 (patch) | |
tree | ef837691e4e0c3df372aaf4c97b0b2e8fde17eb8 | |
parent | 0fa1fdcd78ed7aed7963ba91cc662ca2259eb0de (diff) |
Windows: fix bluetooth pairing status request
When requesting for pairing status, we do not really know if the device
is LE or Classic bluetooth device. Because of that, we try both
options.
The pre-existing code was trying to get an instance of BluetoothDevice
first. In practice, the BluetoothDevice::FromBluetoothAddressAsync()
method returned a correct BluetoothDevice even for LE devices, which
was later leading to an incorrect pairing status, when accessing
device.DeviceInformation().PairingStatus().
This patch re-orders the checks, trying to obtain an LE device first.
My tests show that this approach works correctly for both LE and
Classic devices, because the LE check fails for Classic devices.
Note: Qt 6.2 is unaffected by this bug, because it already checks
LE devices first. The bug was introduces during one of the later
refactorings.
Fixes: QTBUG-113318
Change-Id: I93ada1ca681ec2597809ecba117808d68c2dcb8c
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 3d234d3b182f1759ecf8e5c092948c15f5c3ea4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_winrt.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_winrt.cpp b/src/bluetooth/qbluetoothlocaldevice_winrt.cpp index 72cc4e6a..ec0787dd 100644 --- a/src/bluetooth/qbluetoothlocaldevice_winrt.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_winrt.cpp @@ -465,16 +465,16 @@ static DeviceInformationCollection getAvailableAdapters() DeviceInformationPairing pairingInfoFromAddress(const QBluetoothAddress &address) { const quint64 addr64 = address.toUInt64(); - BluetoothDevice device(nullptr); - bool res = await(BluetoothDevice::FromBluetoothAddressAsync(addr64), device, 5000); - if (res && device) - return device.DeviceInformation().Pairing(); - BluetoothLEDevice leDevice(nullptr); - res = await(BluetoothLEDevice::FromBluetoothAddressAsync(addr64), leDevice, 5000); + bool res = await(BluetoothLEDevice::FromBluetoothAddressAsync(addr64), leDevice, 5000); if (res && leDevice) return leDevice.DeviceInformation().Pairing(); + BluetoothDevice device(nullptr); + res = await(BluetoothDevice::FromBluetoothAddressAsync(addr64), device, 5000); + if (res && device) + return device.DeviceInformation().Pairing(); + return nullptr; } |