feat(connections): list only BLE devices visible via scan#5877
Merged
Conversation
The Connections BLE list merged system-bonded devices (from BluetoothAdapter.getBondedDevices()) into the picker unconditionally — even with no scan running and even when the radio wasn't nearby — so previously paired devices cluttered the list. Restrict bleDevicesForUi to devices the active scan currently sees. A bonded device still appears (and keeps its direct-connect routing) once it's picked up by the scan; bonded devices that aren't advertising are hidden. The currently-selected device is kept regardless of scan visibility so the active connection stays visible and disconnectable — a connected radio stops advertising and would otherwise drop out, taking the connected card's live RSSI with it. Android-only in effect: the desktop/JVM use case never populated the bonded list, so its picker was already scan-driven. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
The Connections BLE picker listed every system-bonded device returned by
BluetoothAdapter.getBondedDevices()unconditionally — even with no scan running and even when the radio wasn't nearby — so previously paired devices cluttered the list. This restricts the BLE list to what's actually visible via the current scan.🌟 Changes
ScannerViewModel.bleDevicesForUinow surfaces a bonded device only when the active scan currently sees it (advertising). Stale system-bonded peripherals that aren't nearby are hidden.bonded, so tapping it connects directly instead of re-running the pairing dialog. Unbonded scanned devices are unchanged (shown, routed through bonding on tap).combinefor this.🛠️ Notes for reviewers
CommonGetDiscoveredDevicesUseCasenever populatesbleDevices, so its picker was already scan-driven — the common-code change filters an already-empty list there.bleAutoScan(auto-starts the scan on screen open) governs whether the list populates immediately.Testing Performed
feature:connectionsScannerViewModelTest(commonTest; runs on both JVM and AndroidHostTest):bleDevicesForUi shows bonded devices only once they are visible via scan(was... sorts by bonded then discovery order, which asserted the now-removed "bonded always shows pre-scan" behavior). Verifies a bonded device stays hidden until the scan sees it, then appears bonded and sorted first, and that RSSI updates don't re-sort.bleDevicesForUi keeps the selected device visible even when not seen via scan.currentDeviceAddressFlowto drive the selected-device path.Verified locally:
./gradlew spotlessApply spotlessCheck detektpass;:feature:connections:allTests --tests "*ScannerViewModelTest*"— all 12 pass.