kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
move disassociate to SettingsFragment
rodzic
0f3135978c
commit
c04c1b4add
|
@ -286,22 +286,6 @@ class RadioInterfaceService : Service(), Logging {
|
||||||
|
|
||||||
debug("Setting bonded device to ${address.anonymize}")
|
debug("Setting bonded device to ${address.anonymize}")
|
||||||
|
|
||||||
// We only keep an association to one device at a time... (move to BluetoothInterface?)
|
|
||||||
if (BluetoothInterface.hasCompanionDeviceApi(this)) {
|
|
||||||
if (address != null) {
|
|
||||||
val deviceManager = getSystemService(CompanionDeviceManager::class.java)
|
|
||||||
val c = address[0]
|
|
||||||
val rest = address.substring(1)
|
|
||||||
|
|
||||||
deviceManager.associations.forEach { old ->
|
|
||||||
if (rest != old) {
|
|
||||||
debug("Forgetting old BLE association ${old.anonymize}")
|
|
||||||
deviceManager.disassociate(old)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getPrefs(this).edit(commit = true) {
|
getPrefs(this).edit(commit = true) {
|
||||||
if (address == null)
|
if (address == null)
|
||||||
this.remove(DEVADDR_KEY)
|
this.remove(DEVADDR_KEY)
|
||||||
|
|
|
@ -1046,6 +1046,14 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
) {
|
) {
|
||||||
val deviceToPair: BluetoothDevice =
|
val deviceToPair: BluetoothDevice =
|
||||||
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
|
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
|
||||||
|
|
||||||
|
// We only keep an association to one device at a time...
|
||||||
|
deviceManager.associations.forEach { old ->
|
||||||
|
if (deviceToPair.address != old) {
|
||||||
|
debug("Forgetting old BLE association ${old.anonymize}")
|
||||||
|
deviceManager.disassociate(old)
|
||||||
|
}
|
||||||
|
}
|
||||||
scanModel.onSelected(
|
scanModel.onSelected(
|
||||||
myActivity,
|
myActivity,
|
||||||
BTScanModel.DeviceListEntry(
|
BTScanModel.DeviceListEntry(
|
||||||
|
|
Ładowanie…
Reference in New Issue