use same CompanionDeviceManager method

pull/372/head
andrekir 2022-02-07 21:46:47 -03:00
rodzic 3001696f9c
commit 45895cdcf6
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -113,7 +113,9 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
@SuppressLint("NewApi", "MissingPermission")
override fun addressValid(context: Context, rest: String): Boolean {
val allPaired = if (hasCompanionDeviceApi(context)) {
val deviceManager = context.getSystemService(CompanionDeviceManager::class.java)
val deviceManager: CompanionDeviceManager by lazy {
context.getSystemService(Context.COMPANION_DEVICE_SERVICE) as CompanionDeviceManager
}
deviceManager.associations.map { it }.toSet()
} else {
getBluetoothAdapter(context)?.bondedDevices.orEmpty()