Device: Start scanning when Bluetooth permission is granted#445
Merged
Conversation
Allow the app to scan for AirPods when only BLE scan permissions are granted, without waiting for all optional permissions (notifications, overlay, etc.). Add isScanBlocking flag to Permission enum. Gate monitor service and pod scanning on scan permissions only. Show scan-blocking permission cards with error color and sorted first. Wrap BLUETOOTH_CONNECT-dependent calls in try-catch for graceful degradation. Fix POST_NOTIFICATIONS minApiLevel from S (31) to TIRAMISU (33).
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.
What changed
The app no longer blocks all functionality when optional permissions (like notifications or overlay) are missing. As soon as the core Bluetooth scanning permission is granted, the app starts scanning for AirPods and showing devices. Other permission cards remain visible but don't prevent scanning.
Permission cards for scan-critical permissions now appear at the top of the list with a distinct color to help users prioritize what to grant first.
Also fixed the notification permission card incorrectly appearing on Android 12-12L (API 31-32) where it can't actually be granted — the runtime notification permission was introduced in Android 13 (API 33).
Technical Context
isScanBlockingflag to thePermissionenum to classify which permissions are required for BLE scanning vs. optional enhancements (BLUETOOTH, BLUETOOTH_SCAN, ACCESS_FINE_LOCATION are scan-blocking; BLUETOOTH_CONNECT, POST_NOTIFICATIONS, etc. are not)PermissionToolexposes a newmissingScanPermissionsflow derived frommissingPermissions. Monitor service, PodMonitor, and ViewModel gate scanning on this instead of all permissionsMonitorControlcheckedBLUETOOTH_CONNECTinstead ofBLUETOOTH_SCANas the scanning gate — fixedBluetoothEventReceiver.hasFeature()andOverviewViewModel.connectedDevicesrequire BLUETOOTH_CONNECT which may not be granted when scanning starts — wrapped in try-catch for graceful degradationBluetoothManager2.connectedDevicesalready handles SecurityException internally (emits empty list), so PopUpReaction, PlayPause, and AutoConnect degrade gracefully without changes