Skip to content

Commit da42d87

Browse files
committed
#1646 fix: disabling Bluetooth clears the list of connected devices
1 parent dd62674 commit da42d87

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
## Bug fixes
1515

1616
- Inputting key events with Shizuku does not crash the app if a Key Mapper keyboard is being used at the same time. And latency when inputting key events has been improved in some apps.
17+
- #1646 disabling Bluetooth clears the list of connected devices
1718

1819
## [3.0.0](https://github.com/sds100/KeyMapper/releases/tag/v3.0.0)
1920

app/src/main/java/io/github/sds100/keymapper/system/devices/AndroidDevicesAdapter.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import kotlinx.coroutines.flow.collectLatest
2222
import kotlinx.coroutines.flow.launchIn
2323
import kotlinx.coroutines.flow.merge
2424
import kotlinx.coroutines.flow.onEach
25+
import kotlinx.coroutines.flow.update
2526
import kotlinx.coroutines.launch
2627
import splitties.mainthread.mainLooper
2728

@@ -109,6 +110,12 @@ class AndroidDevicesAdapter(
109110

110111
connectedBluetoothDevices.value = currentValue.minus(device)
111112
}.launchIn(coroutineScope)
113+
114+
bluetoothAdapter.isBluetoothEnabled.onEach { isEnabled ->
115+
if (!isEnabled) {
116+
connectedBluetoothDevices.update { emptySet() }
117+
}
118+
}.launchIn(coroutineScope)
112119
}
113120

114121
override fun deviceHasKey(id: Int, keyCode: Int): Boolean {

0 commit comments

Comments
 (0)