Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request location permissions for BLE scan on Android 12 and older #126

Merged
merged 2 commits into from
Feb 8, 2025

Conversation

twyatt
Copy link
Contributor

@twyatt twyatt commented Aug 16, 2024

Attempted to use moko-permissions on an Android 11 device (Pixel 2 XL) and found that after granting permissions, scanning would silently not deliver any advertisements. Determined that the problem was missing location permission.

Per Bluetooth permissions documentation, the following permissions are needed for Bluetooth Low Energy scanning (summarized in table form for readability):

Version SDK / API level Version code Permission required
Android 15 Level 35 VANILLA_ICE_CREAM BLUETOOTH_SCAN
Android 14 Level 34 UPSIDE_DOWN_CAKE BLUETOOTH_SCAN
Android 13 Level 33 TIRAMISU BLUETOOTH_SCAN
Android 12 Level 32 S_V2 BLUETOOTH_SCAN
Android 12 Level 31 S BLUETOOTH_SCAN
Android 11 Level 30 R ACCESS_FINE_LOCATION
Android 10 Level 29 Q ACCESS_FINE_LOCATION
Android 9 Level 28 P ACCESS_COARSE_LOCATION
Android 8 Level 27 O_MR1 ACCESS_COARSE_LOCATION
Android 8 Level 26 O ACCESS_COARSE_LOCATION
Android 7 Level 25 N_MR1 ACCESS_COARSE_LOCATION
Android 7 Level 24 N ACCESS_COARSE_LOCATION
Android 6 Level 23 M ACCESS_COARSE_LOCATION
Android 5 Level 22 LOLLIPOP_MR1 ACCESS_COARSE_LOCATION
Android 5 Level 21 LOLLIPOP, L ACCESS_COARSE_LOCATION

Tested these changes as working on:

Phone Android version Permission requirement
Google Pixel 5 Android 14 BLUETOOTH_SCAN
Google Pixel 2 XL Android 11 ACCESS_FINE_LOCATION
Samsung Galaxy J5 Android 5.1.1 ACCESS_COARSE_LOCATION

@twyatt twyatt marked this pull request as ready for review August 16, 2024 01:17
@twyatt
Copy link
Contributor Author

twyatt commented Aug 16, 2024

I have not tested permission for BLE connect yet, expect an additional PR if changes are needed there as well.

@Alex009 Alex009 self-requested a review August 16, 2024 01:50
@Alex009 Alex009 changed the base branch from master to develop September 28, 2024 05:46
@twyatt
Copy link
Contributor Author

twyatt commented Oct 13, 2024

I have not tested permission for BLE connect yet, expect an additional PR if changes are needed there as well.

Tested the BLUETOOTH_CONNECT and found that no changes are needed in moko permissions.

Tested with:

Phone Android version Permission requirement
Google Pixel 5 Android 14
  • If BLUETOOTH_SCAN is granted, will connect w/o requesting BLUETOOTH_CONNECT
  • If BLUETOOTH_SCAN is not requested prior, BLUETOOTH_CONNECT is needed to connect
Google Pixel 2 XL Android 11 None (connects w/o requesting BLUETOOTH_CONNECT; if requested, BLUETOOTH_CONNECT is granted immediately w/o showing dialog)
Samsung Galaxy J5 Android 5.1.1 None (connects w/o requesting BLUETOOTH_CONNECT; if requested, BLUETOOTH_CONNECT is granted immediately w/o showing dialog)

Note

All devices tested immediately grant permission (without showing dialog) when requesting BLUETOOTH_CONNECT if BLUETOOTH_SCAN was already granted.

…missions

# Conflicts:
#	permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionsControllerImpl.kt
@Alex009 Alex009 added this to the 0.19.0 milestone Feb 8, 2025
@Alex009 Alex009 merged commit 48c7693 into icerockdev:develop Feb 8, 2025
1 check passed
@Alex009 Alex009 linked an issue Feb 8, 2025 that may be closed by this pull request
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.

Localization permission for BLE devices on Android >=12
2 participants