Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
6.5.7
-
Pixel 7, Android 14
Description
Code
#include <QApplication> #include <QVBoxLayout> #include <QPushButton> #include <QBluetoothDeviceDiscoveryAgent> #include <QPermissions> int main(int argc, char *argv[]) { QApplication app(argc, argv); QBluetoothPermission p; qDebug() << "Bluetooth permission status:" << app.checkPermission(p); QBluetoothDeviceDiscoveryAgent agent; QObject::connect(&agent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, &app, [](const QBluetoothDeviceInfo& info){ qDebug() << "Discovered device:" << info.name(); }); QWidget win; auto layout = new QVBoxLayout(&win); auto btn_req = new QPushButton ("Request Bluetooth Permissions"); auto btn_scan = new QPushButton ("Start Scanning"); layout->addWidget(btn_req); layout->addWidget(btn_scan); win.show(); QObject::connect(btn_req, &QPushButton::clicked, &app, [&] { app.requestPermission(p, &app, [&]{ qDebug() << "Permission requested."; qDebug() << "Bluetooth permission status:" << app.checkPermission(p); }); }); QObject::connect(btn_scan, &QPushButton::clicked, &app, [&] { agent.start(); qDebug() << "Started trying to scan"; qDebug() << "Bluetooth permission status:" << app.checkPermission(p); }); return app.exec(); }
Steps to reproduce
- Build and run the code above
- Click "Start Scanning"
- When the (automatic) permission dialog pops up, select "Don't allow"
Outcomes
At startup (Step #1), we immediately see Bluetooth permission status: Qt::PermissionStatus::Granted. (The expected status is Qt::PermissionStatus::Undetermined)
After Step #2, we see the following debug output:
W qt.bluetooth.android: : Search not possible due to missing permission (ACCESS_FINE_LOCATION) D libBluetoothPermissionsStudy_arm64-v8a.so: Started trying to scan D libBluetoothPermissionsStudy_arm64-v8a.so: Bluetooth permission status: Qt::PermissionStatus::Granted
(The expected status is Qt::PermissionStatus::Denied)
After Step #3, the permission dialog does not appear again, yet we see the following debug output:
D libBluetoothPermissionsStudy_arm64-v8a.so: Permission requested. D libBluetoothPermissionsStudy_arm64-v8a.so: Bluetooth permission status: Qt::PermissionStatus::Granted
(The expected status is Qt::PermissionStatus::Denied)
Summary
The Qt app will work fine if the user provides all the necessary permissions. But if the user denies a Bluetooth-related permission, the Qt app is still told that the permission is granted. It has no way of gracefully switching to reduced-functionality mode, or informing the user of the missing permission.
Qt 6.7 and newer behaves correctly.
Attachments
Issue Links
- relates to
-
QTBUG-130372 Doc: Make QtAndroidPrivate::checkPermission() and QtAndroidPrivate::requestPermission() point to QPermission
- Closed