Prevent the app crash when Improv scanning fails in any way by catching the exceptions, we should always fail silently here. Also added a quick check in case the issue is caused by no BLE support but that seems unlikely.
Fixes:
Exception java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.startScan(java.util.List, android.bluetooth.le.ScanSettings, android.bluetooth.le.ScanCallback)' on a null object reference
at com.wifi.improv.ImprovManager.findDevices (ImprovManager.kt:243)
at io.homeassistant.companion.android.improv.ImprovRepositoryImpl.startScanning (ImprovRepositoryImpl.kt:65)
at io.homeassistant.companion.android.webview.WebViewPresenterImpl$startScanningForImprov$1$1.invokeSuspend (WebViewPresenterImpl.kt:488)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:101)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run (LimitedDispatcher.kt:113)
at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:589)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:823)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:720)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:707)
Summary
Prevent the app crash when Improv scanning fails in any way by catching the exceptions, we should always fail silently here. Also added a quick check in case the issue is caused by no BLE support but that seems unlikely.
Fixes:
Screenshots
n/a
Link to pull request in Documentation repository
n/a
Any other notes