Skip to content

fix(#134): honor neverForLocation when checking ble scan permissions - #135

Merged
mateogianolio merged 1 commit into
orbital-systems:masterfrom
q-bird:fix-134
Aug 18, 2026
Merged

mateogianolio merged 1 commit into
orbital-systems:masterfrom
q-bird:fix-134

Conversation

@q-bird

@q-bird q-bird commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #134.

hasFineLocationPermission() was applied unconditionally to the BLE paths. Since API 31, an app that declares BLUETOOTH_SCAN with neverForLocation can scan without ACCESS_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.requestedPermissionsFlags and REQUESTED_PERMISSION_NEVER_FOR_LOCATION:

  • app declares neverForLocation -> location is not required (API 31+)
  • app does not declare it -> location is still required, unchanged
  • API <= 30 -> unchanged

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 in createESPDevice. 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_SCAN without neverForLocation and adds ACCESS_FINE_LOCATION to ANDROID_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.

@mateogianolio mateogianolio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch and thank you for your contribution! Adding an option for the expo plugin in a separate PR would be great 👍

@mateogianolio
mateogianolio merged commit 5aba554 into orbital-systems:master Aug 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLE scan blocked by ACCESS_FINE_LOCATION check on Android 12+

2 participants