Decouple location and bluetooth permissions if API level >= 31
This is a manual cherry-pick from bb8cf72233e05c88424d525ca578cbf21d66c938 With minor documentation modification (6.8.1 instead of 6.9) Since Android-12 / API-level 31, the ACCESS_FINE_LOCATION is no longer mandatory for Bluetooth usage. Removing it will avoid unnecessary location permission query (user prompt). There are less common use cases to derive the location too. In these cases the user must override the BLUETOOTH_SCAN permission so that it no longer asserts neverForLocation, and also request the ACCESS_FINE_LOCATION permission separately (QLocationPermission). This change relates to QtBluetooth change, which adds android:usesPermissionFlags="neverForLocation" attribute to BLUETOOTH_SCAN permission (in default-generated AndroidManifest.xml) [ChangeLog][Important Behavior Changes][QBluetoothPermission] ACCESS_FINE_LOCATION is no longer requested if API-level >= 31 Task-number: QTBUG-129944 Task-number: QTBUG-117358 Task-number: QTBUG-112164 Change-Id: I774d0aada4c08829860d252a616fd0c3992a853d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit bb8cf72233e05c88424d525ca578cbf21d66c938)
This commit is contained in:
parent
e6aa48dc2c
commit
e28adc19ed
@ -177,3 +177,7 @@
|
||||
\title Java arrays
|
||||
*/
|
||||
|
||||
/*!
|
||||
\externalpage https://developer.android.com/develop/connectivity/bluetooth/bt-permissions
|
||||
\title Android Bluetooth Permissions
|
||||
*/
|
||||
|
@ -371,16 +371,17 @@ QT_PERMISSION_IMPL_COMMON(QMicrophonePermission)
|
||||
\li \c android.permission.BLUETOOTH_ADVERTISE
|
||||
\li \c android.permission.BLUETOOTH_CONNECT
|
||||
\li \c android.permission.BLUETOOTH_SCAN
|
||||
\li \c android.permission.ACCESS_FINE_LOCATION
|
||||
\endlist
|
||||
\include permissions.qdocinc end-usage-declarations
|
||||
|
||||
\note Currently on Android the \c android.permission.ACCESS_FINE_LOCATION
|
||||
permission is requested together with Bluetooth permissions. This is
|
||||
required for Bluetooth to work properly, unless the application provides a
|
||||
strong assertion in the application manifest that it does not use Bluetooth
|
||||
to derive a physical location. This permission coupling may change in
|
||||
future.
|
||||
\note Since Qt 6.8.1, the ACCESS_FINE_LOCATION permission is no longer
|
||||
requested if API Level >= 31. This
|
||||
\l {Android Bluetooth Permissions}{may limit some Bluetooth scan results}.
|
||||
Users needing these results need
|
||||
to request the location permission separately (see
|
||||
\l {QLocationPermission::Precise}{precise location}) and ensure that
|
||||
\c {BLUETOOTH_SCAN} permission doesn't have the
|
||||
\c {android:usesPermissionFlags="neverForLocation"} attribute set.
|
||||
|
||||
\include permissions.qdocinc permission-metadata
|
||||
*/
|
||||
@ -403,10 +404,6 @@ QT_PERMISSION_IMPL_COMMON(QBluetoothPermission)
|
||||
\note The fine-grained permissions are currently supported only on
|
||||
Android 12 and newer. On older Android versions, as well as on Apple
|
||||
operating systems, any mode results in full Bluetooth access.
|
||||
|
||||
\note For now the \c Access mode on Android also requests the
|
||||
\l {QLocationPermission::Precise}{precise location} permission.
|
||||
This permission coupling may change in the future.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -56,13 +56,11 @@ static QStringList nativeBluetoothPermission(const QBluetoothPermission &permiss
|
||||
|
||||
// API Level < 31
|
||||
static QString bluetoothGeneral = u"android.permission.BLUETOOTH"_s;
|
||||
static QString fineLocation = u"android.permission.ACCESS_FINE_LOCATION"_s;
|
||||
// API Level >= 31
|
||||
static QString bluetoothScan = u"android.permission.BLUETOOTH_SCAN"_s;
|
||||
static QString bluetoothAdvertise = u"android.permission.BLUETOOTH_ADVERTISE"_s;
|
||||
static QString bluetoothConnect = u"android.permission.BLUETOOTH_CONNECT"_s;
|
||||
// Fine location is currently required for ALL API levels, but that is not
|
||||
// strictly necessary for API Level >= 31. See QTBUG-112164.
|
||||
static QString fineLocation = u"android.permission.ACCESS_FINE_LOCATION"_s;
|
||||
|
||||
if (QtAndroidPrivate::androidSdkVersion() < 31) {
|
||||
return {bluetoothGeneral, fineLocation};
|
||||
@ -72,7 +70,7 @@ static QStringList nativeBluetoothPermission(const QBluetoothPermission &permiss
|
||||
if (modes & QBluetoothPermission::Advertise)
|
||||
permissionList << bluetoothAdvertise;
|
||||
if (modes & QBluetoothPermission::Access)
|
||||
permissionList << bluetoothScan << bluetoothConnect << fineLocation;
|
||||
permissionList << bluetoothScan << bluetoothConnect;
|
||||
return permissionList;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user