diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-04-05 17:30:03 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-05-03 12:08:47 +0200 |
commit | 06d37147d1b59ca8cb5ce526a96b4ba59e44e0fa (patch) | |
tree | 43376a1bf65816df1455d3505e73925bad3dd177 /src/bluetooth/qbluetoothlocaldevice_android.cpp | |
parent | a75d7fac5b555271902e02d63b4c4fb32cf4c008 (diff) | |
download | qtconnectivity-06d37147d1b59ca8cb5ce526a96b4ba59e44e0fa.tar.gz |
QtBluetooth: use public QPermission API to check for permissions on Android
Now when we have the fine-grained public QBluetoothPermission API, we
can use it to check for permissions in the Android implementation.
Adapt QtBluetooth examples to use only the minimal required set of
permissions.
As a drive-by: fix a couple of qCWarning() strings.
Task-number: QTBUG-109964
Change-Id: I55c67bcae27926e76bf9c1a8a9367af2b58883ff
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothlocaldevice_android.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_android.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_android.cpp b/src/bluetooth/qbluetoothlocaldevice_android.cpp index ca7faed0..381f3c15 100644 --- a/src/bluetooth/qbluetoothlocaldevice_android.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_android.cpp @@ -55,8 +55,7 @@ void QBluetoothLocalDevicePrivate::initialize(const QBluetoothAddress &address) return; } - if (!(ensureAndroidPermission(BluetoothPermission::Scan) && - ensureAndroidPermission(BluetoothPermission::Connect))) { + if (!ensureAndroidPermission(QBluetoothPermission::Access)) { qCWarning(QT_BT_ANDROID) << "Local device initialize() failed due to missing permissions"; return; } @@ -244,8 +243,8 @@ void QBluetoothLocalDevice::setHostMode(QBluetoothLocalDevice::HostMode requeste } case QBluetoothLocalDevice::HostDiscoverable: { - if (!ensureAndroidPermission(BluetoothPermission::Advertise)) { - qCWarning(QT_BT_ANDROID) << "Local device setHostMode() failed due to" + if (!ensureAndroidPermission(QBluetoothPermission::Advertise)) { + qCWarning(QT_BT_ANDROID) << "Local device setHostMode() failed due to " "missing permissions"; emit errorOccurred(QBluetoothLocalDevice::MissingPermissionsError); return; @@ -288,8 +287,8 @@ QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices() { // As a static class function we need to ensure permissions here (in addition to initialize()) - if (!ensureAndroidPermission(BluetoothPermission::Connect)) { - qCWarning(QT_BT_ANDROID) << "Local device allDevices() failed due to" + if (!ensureAndroidPermission(QBluetoothPermission::Access)) { + qCWarning(QT_BT_ANDROID) << "Local device allDevices() failed due to " "missing permissions"; return {}; } |