summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-03-31 12:16:42 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-04-05 10:00:53 +0200
commitdd011e93e3f2868eaf99969cc9f782dcdb0bf2cf (patch)
tree803ba39379b74dfd9071a48923b5631a323ec1a7
parentbffe878c4b93cbf1854cb4c5c0a75250f4dfaa9a (diff)
downloadqtconnectivity-dd011e93e3f2868eaf99969cc9f782dcdb0bf2cf.tar.gz
QtBluetooth: do not request permissions on Android
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 <juha.vuolle@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/bluetooth/android/androidutils.cpp4
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc10
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp17
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";