fix(bluetooth): Check for permissions before accessing bonded devices (#3720)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-11-17 06:35:33 -06:00 committed by GitHub
parent d6f39fdcb5
commit 12ccb34553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 14 deletions

View file

@ -160,11 +160,13 @@ constructor(
Timber.d("Detected our bluetooth access=$newState")
}
private fun getBondedAppPeripherals(enabled: Boolean): List<Peripheral> = if (enabled) {
centralManager.getBondedPeripherals().filter(::isMatchingPeripheral)
} else {
emptyList()
}
@SuppressLint("MissingPermission")
private fun getBondedAppPeripherals(enabled: Boolean): List<Peripheral> =
if (enabled && application.hasBluetoothPermission()) {
centralManager.getBondedPeripherals().filter(::isMatchingPeripheral)
} else {
emptyList()
}
/** Checks if a peripheral is one of ours, either by its advertised name or by the services it provides. */
@OptIn(ExperimentalUuidApi::class)