From dd011e93e3f2868eaf99969cc9f782dcdb0bf2cf Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Fri, 31 Mar 2023 12:16:42 +0200 Subject: QtBluetooth: do not request permissions on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expect it to be done on the application side. The library only checks for the needed permissions. Task-number: QTBUG-109964 Change-Id: Ibb6b756ddea13c14a4c096d200418923e9ccd69c Reviewed-by: Juha Vuolle Reviewed-by: Tor Arne Vestbø --- src/bluetooth/android/androidutils.cpp | 4 ---- src/bluetooth/doc/src/bluetooth-index.qdoc | 10 ++++++++++ .../qbluetoothdevicediscoveryagent_android.cpp | 17 +++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/bluetooth/android/androidutils.cpp b/src/bluetooth/android/androidutils.cpp index 7b7c9cc1..7c99bad3 100644 --- a/src/bluetooth/android/androidutils.cpp +++ b/src/bluetooth/android/androidutils.cpp @@ -36,10 +36,6 @@ bool ensureAndroidPermission(BluetoothPermission permission) if (QtAndroidPrivate::checkPermission(permString).result() == QtAndroidPrivate::Authorized) return true; - // If we didn't have the permission, request it - if (QtAndroidPrivate::requestPermission(permString).result() == QtAndroidPrivate::Authorized) - return true; - qCWarning(QT_BT_ANDROID) << "Permission not authorized:" << permString; return false; } diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc index 5a2f45a6..1a275a17 100644 --- a/src/bluetooth/doc/src/bluetooth-index.qdoc +++ b/src/bluetooth/doc/src/bluetooth-index.qdoc @@ -66,6 +66,16 @@ use cases. Further details can be found in the \include {module-use.qdocinc} {building_with_qmake} {bluetooth} +\section1 Permissions + +Starting from Qt 6.6, the Qt Bluetooth module uses new \l QPermission API +to handle \l {QBluetoothPermission}{Bluetooth} permissions. This means that Qt +itself no longer queries for these permissions, so this needs to be done +directly from the client application. + +Please refer to the \l {Application Permissions} page for an example of how +to integrate the new \l QPermission API into the application. + \section1 Related Information \section2 Building Qt Bluetooth diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp index b52313e0..54d0cdae 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp @@ -136,16 +136,13 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent auto precisePermission = QStringLiteral("android.permission.ACCESS_FINE_LOCATION"); auto preciseCheckRes = QtAndroidPrivate::checkPermission(precisePermission).result(); if (preciseCheckRes != QtAndroidPrivate::Authorized) { - auto preciseRequestRes = QtAndroidPrivate::requestPermission(precisePermission).result(); - if (preciseRequestRes != QtAndroidPrivate::Authorized) { - qCWarning(QT_BT_ANDROID) << - "Search not possible due to missing permission (ACCESS_FINE_LOCATION)"; - errorString = QBluetoothDeviceDiscoveryAgent::tr( - "Missing Location permission. Search is not possible."); - lastError = QBluetoothDeviceDiscoveryAgent::MissingPermissionsError; - emit q->errorOccurred(lastError); - return; - } + qCWarning(QT_BT_ANDROID) << + "Search not possible due to missing permission (ACCESS_FINE_LOCATION)"; + errorString = QBluetoothDeviceDiscoveryAgent::tr( + "Missing Location permission. Search is not possible."); + lastError = QBluetoothDeviceDiscoveryAgent::MissingPermissionsError; + emit q->errorOccurred(lastError); + return; } qCDebug(QT_BT_ANDROID) << "ACCESS_FINE_LOCATION permission available"; -- cgit v1.2.1