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,11 +219,13 @@ 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) {
if (bluetoothAdapter?.isEnabled == true && bluetoothAdapter?.state == BluetoothAdapter.STATE_ON) {
bleScanner?.startScan(filters, settings, bleScanCallback) bleScanner?.startScan(filters, settings, bleScanCallback)
aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start") aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start")
Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show() Toast.makeText(this@RileyLinkBLEConfigActivity, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show()
} }
} }
}
private fun stopLeDeviceScan() { private fun stopLeDeviceScan() {
if (scanning) { if (scanning) {