-
Notifications
You must be signed in to change notification settings - Fork 590
Description
Describe the bug
Scan permissions handling does not seem to be correct for apps with target sdk less than 31
It appears to me that on later android versions (likely 12+ but only tested on 16) that the presence of the BLUETOOTH_SCAN permission in the manifest means that the permission handler for bluetooth requires this permission to be granted even if the app targets a lower sdk version before this permission was introduced.
This behavior differs from other ways that target sdk affects how the android framework treats apps.
I believe that the fix would be in ClientComponent.java provideRecommendedScanRuntimePermissionNames to change the line which says:
int sdkVersion = Math.min(deviceSdk, targetSdk);
To something like:
boolean permissionsPresentEvenWithLowerTargetSdk = (targetSdk < 31 && deviceSdk >= 31) && isNearbyServicesNeverForLocation;
int sdkVersion = permissionsPresentEvenWithLowerTargetSdk ? deviceSdk : Math.min(deviceSdk, targetSdk);
What do you think? I can provide a PR for this fix which I am currently testing on a local fork.