RL: prevent crash with BT off

This commit is contained in:
Milos Kozak 2023-10-31 09:17:54 +01:00
parent 6c604e923f
commit 656e3e44be

View file

@ -219,9 +219,11 @@ class RileyLinkBLEConfigActivity : TranslatedDaggerAppCompatActivity() {
} }
scanning = true scanning = true
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED) {
bleScanner?.startScan(filters, settings, bleScanCallback) if (bluetoothAdapter?.isEnabled == true && bluetoothAdapter?.state == BluetoothAdapter.STATE_ON) {
aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start") bleScanner?.startScan(filters, settings, bleScanCallback)
Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show() aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start")
Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show()
}
} }
} }