return from scanning if permission is not granted

This commit is contained in:
Dorian Zedler 2020-10-18 03:32:39 +02:00
parent 35ff374658
commit fba59b3777
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37

View file

@ -36,7 +36,7 @@ bool QBluetoothLeUartClient::startScanningForDevices(){
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
else if(this->state == LocationPermissionDenied) { else if(this->state == LocationPermissionDenied) {
// try to get permission // try to get permission
QtAndroid::PermissionResultMap resultMap = QtAndroid::requestPermissionsSync({"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"}, 5000); QtAndroid::PermissionResultMap resultMap = QtAndroid::requestPermissionsSync({"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"});
bool resultBool = true; bool resultBool = true;
for(QtAndroid::PermissionResult result : resultMap) { for(QtAndroid::PermissionResult result : resultMap) {
if(result != QtAndroid::PermissionResult::Granted) { if(result != QtAndroid::PermissionResult::Granted) {
@ -47,6 +47,7 @@ bool QBluetoothLeUartClient::startScanningForDevices(){
if(!resultBool) { if(!resultBool) {
emit this->scanningErrorOccured(LocationPermissionDeniedError); emit this->scanningErrorOccured(LocationPermissionDeniedError);
return false;
} }
} }