I am working on a Android application that uses bluetooth and I want to use the new Android 12 Bluetooth_SCAN and CONNECT permissions to remove the need for location permission using
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
As shown in the bluetooth documentation
The problem is, the application has one main feature and one optional. The main feature works fine with these permissions.
However, the optional feature uses beacon scanning. These beacons are filtered out from scanning by the Android OS when using the "neverForLocation" flag.
Note: If you include neverForLocation in your android:usesPermissionFlags, some BLE beacons are filtered from the scan results.
The beacons appear during scanning if the flag is removed from the manifest permission.
However, if i remove this flag from the manifest, then even users that don't want to use this feature have to provide the location permission, or else the normal BLEScan returns nothing. This is something that i would like to avoid giving the fact that the whole reason for these new permission is to avoid asking the user for location.
Is there a way to provide this flag when making the actual runtime request to the OS for the permission instead of it being declared in the manifest? Any help or idea is appreciated.