From 57c612abceaeb58a3d8751b4c7d3d2f356b9973c Mon Sep 17 00:00:00 2001 From: James Rich Date: Mon, 20 Apr 2026 11:51:41 -0500 Subject: [PATCH] fix(ble): filter bonded picker list to Meshtastic devices BluetoothAdapter.bondedDevices returns every paired BT device on the phone (headphones, cars, watches, etc.). The picker's bondedBleFlow was mapping the full set into DeviceListEntry.Ble with no filter, leaking non-Meshtastic devices into the connection list. Apply the existing Meshtastic name pattern (getMeshtasticShortName()) at the use-case layer. Repository semantics are preserved so BleRadioTransport.findDevice() can still resolve a saved address regardless of name conventions. The active scan path (KableBleScanner) already filters by SERVICE_UUID and is unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt index b0a3d738c..b6999aadc 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt +++ b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt @@ -60,7 +60,14 @@ class AndroidGetDiscoveredDevicesUseCase( override fun invoke(showMock: Boolean): Flow { val nodeDb = nodeRepository.nodeDBbyNum - val bondedBleFlow = bluetoothRepository.state.map { ble -> ble.bondedDevices.map { DeviceListEntry.Ble(it) } } + // Filter out non-Meshtastic peripherals (headphones, cars, watches, etc.). + // BluetoothAdapter.bondedDevices returns every bonded device on the phone, so we + // must restrict the picker to entries whose advertised name matches the + // Meshtastic firmware pattern (see MeshtasticBleConstants.BLE_NAME_PATTERN). + val bondedBleFlow = + bluetoothRepository.state.map { ble -> + ble.bondedDevices.filter { it.getMeshtasticShortName() != null }.map { DeviceListEntry.Ble(it) } + } val processedTcpFlow = combine(networkRepository.resolvedList, recentAddressesDataSource.recentAddresses) {