Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › LOCATION needed for BLE scan even for Android 12

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24753

    Allan

    Hello,

     

    There are some changes in BLE scanning for Android 12.

    New permissions are required and the location is no more needed.

     

    The problem is that when I start a Scan it keeps asking for the location to be enabled.

    I am missing something ?

     

    Here is my permission setup :

        <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
        <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
        <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
        <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"/>
    
        <!--<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" android:maxSdkVersion="30"/>-->
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
        <uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
        <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
        <uses-feature android:name="android.hardware.location"/>
    
        <uses-feature android:name="android.hardware.screen.portrait"/>

    note: the ACCESS_COARSE_LOCATION should be with android:maxSdkVersion="30" but in that case the scan is not working.

    I also added in my C++ (before scanning) :

    #ifndef Q_OS_MAC
    bool Ble_Central::requestPermission(void) {
       QString scanPerm = "android.permission.BLUETOOTH_SCAN";
       QString connPerm = "android.permission.BLUETOOTH_CONNECT";
       if(QtAndroid::androidSdkVersion() >= 31) {
           auto results = QtAndroid::requestPermissionsSync(QStringList{scanPerm, connPerm});
           if (!results.contains(scanPerm) || results[scanPerm] == QtAndroid::PermissionResult::Denied) {
               qWarning() << "Couldn't get permission: " << scanPerm;
               return false;
           }
           if (!results.contains(connPerm) || results[connPerm] == QtAndroid::PermissionResult::Denied) {
               qWarning() << "Couldn't get permission: " << connPerm;
               return false;
           }
       }
       return true;
    }
    #else
    bool Ble_Central::requestPermission(void) {
       return true;
    }
    #endif

     

    If I’m correct, QT is always asking for the location, not checking the sdk.
    The scan is also not asking BLUETOOTH_SCAN and BLUETOOTH_CONNECT so I need to do it manually.

     

    Do you have a fix for this behavior ?

     

    Cordially,

    Allan

    #24756

    Alex
    Felgo Team

    Hi Allen,

    thanks for the report, I will check back with the dev team quickly. I see that there is a fix for this cherry picked to Qt 5.15.10 and Qt 6.x

    Maybe we need to do the same for the main Felgo version or can offer a Qt Marketplace version with this fix. I will keep you updated

    Best,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded