summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-11-10 22:42:26 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-11-10 22:42:26 +0200
commite957d4810b05d8453e163d7bcdcab42d3c60a7bb (patch)
tree76ed3d969c478042f8ca747bf425b0e5d2e893dc /src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
parent47c424c7990061714bd3108e3fbaa4339ba411b9 (diff)
parenta6f5b79169991ffde38643d7b1a04d6a9de137bf (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.8' into tqtc/lts-5.15-opensourcev5.15.8-lts-lgpl
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
index d9883d28..a5cb034a 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_darwin.mm
@@ -144,6 +144,8 @@ bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods methods)
{
+ using namespace OSXBluetooth;
+
Q_ASSERT(!isActive());
Q_ASSERT(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError);
Q_ASSERT(methods & (QBluetoothDeviceDiscoveryAgent::ClassicMethod
@@ -157,6 +159,25 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent
}
#endif // Q_OS_MACOS
+ // To be able to scan for devices, iOS requires Info.plist containing
+ // NSBluetoothAlwaysUsageDescription entry with a string, explaining
+ // the usage of Bluetooth interface. macOS also requires this description,
+ // starting from Monterey.
+
+ // No Classic on iOS, and Classic does not require a description on macOS:
+ if (methods.testFlag(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod)
+ && qt_appNeedsBluetoothUsageDescription()
+ && !qt_appPlistContainsDescription(bluetoothUsageKey)) {
+ // This would result in Bluetooth framework throwing an exception
+ // the moment we try to start device discovery.
+ qCWarning(QT_BT_OSX)
+ << "A proper Info.plist with NSBluetoothAlwaysUsageDescription "
+ "entry is required, cannot start device discovery";
+ setError(QBluetoothDeviceDiscoveryAgent::UnsupportedDiscoveryMethod);
+ emit q_ptr->error(lastError);
+ return;
+ }
+
requestedMethods = methods;
if (stopPending) {