Skip to content

Commit f7e31a6

Browse files
committed
fix: add ACTION_ACL_CONNECTED and ACTION_ACL_DISCONNECTED to broadcast receiver
1 parent 246bb1f commit f7e31a6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

system/src/main/java/io/github/sds100/keymapper/system/bluetooth/AndroidBluetoothAdapter.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ class AndroidBluetoothAdapter @Inject constructor(
4545
onReceiveIntent(intent)
4646
}
4747
}
48-
4948
init {
5049
IntentFilter().apply {
5150
// these broadcasts can't be received from a manifest declared receiver on Android 8.0+
5251
addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED)
5352
addAction(BluetoothAdapter.ACTION_STATE_CHANGED)
53+
addAction(BluetoothDevice.ACTION_ACL_CONNECTED)
54+
addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED)
5455

5556
ContextCompat.registerReceiver(
5657
ctx,
@@ -112,9 +113,9 @@ class AndroidBluetoothAdapter @Inject constructor(
112113
coroutineScope.launch {
113114
val address = device.address ?: return@launch
114115
val name = device.name ?: return@launch
115-
val bondState = intent.getStringExtra(BluetoothDevice.EXTRA_BOND_STATE)
116+
val bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1)
116117

117-
Timber.i("On Bluetooth device bond state changed to ${bondState.toString()}: $name")
118+
Timber.i("On Bluetooth device bond state changed to $bondState: $name")
118119

119120
onDevicePairedChange.emit(
120121
BluetoothDeviceInfo(

0 commit comments

Comments
 (0)