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