list devices from adapter.bondedDevices (#536)

This commit is contained in:
Andre K 2022-12-10 00:16:14 -03:00 committed by GitHub
parent 6ede4ed3bd
commit d538c2afff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View file

@ -65,6 +65,13 @@ class BluetoothRepository @Inject constructor(
return bluetoothAdapterLazy.get()?.bluetoothLeScanner
}
@SuppressLint("MissingPermission")
fun getBondedDevices(): Set<BluetoothDevice>? {
return bluetoothAdapterLazy.get()
?.takeIf { application.hasBluetoothPermission() }
?.bondedDevices
}
@SuppressLint("MissingPermission")
internal suspend fun updateBluetoothState() {
val newState: BluetoothState = bluetoothAdapterLazy.get()?.takeIf {