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

Forums

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

Viewing 6 posts - 1 through 6 (of 6 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

    #24824

    Alex
    Felgo Team

    Hi Allan,

    We currently prepare an updated Qt Bluetooth library that fixes the issue, so that the location permission is not required anymore for Android 12+. We will ship the fix with one of the following Felgo updates. If you need a fix right now, please reach out to support@felgo.com, referencing this forum conversation.

    Thanks,

    Alex from Felgo

    #24825

    Allan

    Hi,

     

    Thanks, I will wait for the next update.

     

    Cordially.

    #24912

    Allan

    Hello,

    I’m reviving this thread.

    I’m now using Felgo 4, everything works fine, no need to manually ask for permission this time.

    The problem is, it keeps asking for the location. Do you have a working example that I can use ?

    Thanks.

    #24918

    Alex
    Felgo Team

    Hi Allan,

    we’ll patch this with the next F4 release, thanks for your report.

    Best,
    Alex

Viewing 6 posts - 1 through 6 (of 6 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