From 28b905db231c71152bb0616bc605cfefeaf35921 Mon Sep 17 00:00:00 2001 From: andrekir Date: Thu, 13 Apr 2023 17:11:40 -0300 Subject: [PATCH] fix: improve null-safety handling in filter logic to avoid NullPointerException: it.name must not be null at com.geeksville.mesh.repository.bluetooth.BluetoothRepository$createBondedDevicesFlow$2.invokeSuspend(BluetoothRepository.kt:96) --- .../geeksville/mesh/repository/bluetooth/BluetoothRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/repository/bluetooth/BluetoothRepository.kt b/app/src/main/java/com/geeksville/mesh/repository/bluetooth/BluetoothRepository.kt index 7cfbfa0c8..1ab08434e 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/bluetooth/BluetoothRepository.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/bluetooth/BluetoothRepository.kt @@ -93,7 +93,7 @@ class BluetoothRepository @Inject constructor( return flow> { val devices = adapter.bondedDevices ?: emptySet() while (true) { - emit(devices.filter { it.name != null && it.name.matches(Regex(BLE_NAME_PATTERN)) }) + emit(devices.filter { it.name?.matches(Regex(BLE_NAME_PATTERN)) == true }) delay(REFRESH_DELAY_MS) } }.flowOn(dispatchers.default).distinctUntilChanged()