RL: prevent crash when BT is OFF

This commit is contained in:
Milos Kozak 2022-02-08 17:48:33 +01:00
parent fd9d676b92
commit 55ddf6ae42

View file

@ -214,7 +214,8 @@ class RileyLinkBLEConfigActivity : NoSplashAppCompatActivity() {
private fun stopLeDeviceScan() {
if (scanning) {
scanning = false
bleScanner?.stopScan(bleScanCallback)
if (bluetoothAdapter?.isEnabled == true && bluetoothAdapter?.state == BluetoothAdapter.STATE_ON)
bleScanner?.stopScan(bleScanCallback)
aapsLogger.debug(LTag.PUMPBTCOMM, "stopLeDeviceScan: Scanning Stop")
Toast.makeText(this, R.string.riley_link_ble_config_scan_finished, Toast.LENGTH_SHORT).show()
handler.removeCallbacks(stopScanAfterTimeoutRunnable)