fix(#134): honor neverForLocation when checking ble scan permissions - #135
Merged
Merged
Conversation
mateogianolio
approved these changes
Aug 18, 2026
mateogianolio
left a comment
Member
There was a problem hiding this comment.
Great catch and thank you for your contribution! Adding an option for the expo plugin in a separate PR would be great 👍
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #134.
hasFineLocationPermission()was applied unconditionally to the BLE paths. Since API 31, an app that declaresBLUETOOTH_SCANwithneverForLocationcan scan withoutACCESS_FINE_LOCATION, so for those apps the check can never pass - there is no location prompt to grant.Rather than dropping the check on API 31+ outright, this reads the flag the app actually declared, via
PackageInfo.requestedPermissionsFlagsandREQUESTED_PERMISSION_NEVER_FOR_LOCATION:neverForLocation-> location is not required (API 31+)So this is a no-op for existing consumers that don't opt in, and unblocks the ones that do.
Applied to the three BLE call sites:
searchESPDevices(BLE branch),stopESPDevicesSearch, and the BLE search increateESPDevice. The Wi-Fi and SoftAP checks are deliberately left alone - Wi-Fi scanning does require location.Not covered here: the Expo plugin still writes
BLUETOOTH_SCANwithoutneverForLocationand addsACCESS_FINE_LOCATIONtoANDROID_BLE_PERMISSIONS(plugin/index.js), so Expo consumers need a manifest mod of their own to benefit. Happy to follow up with a plugin option in a separate PR if you'd like.