From 58a34a1623f1f750fd38cad78c176ab249878ac4 Mon Sep 17 00:00:00 2001 From: Steve Grosbois Date: Tue, 31 May 2022 10:08:36 +0200 Subject: [PATCH] fix: Fixed bluetooth manual disconnection when bluetooth is back in the second --- .../java/com/welie/blessed/BluetoothCentralManager.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt b/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt index 2c3f124..0784b96 100644 --- a/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt +++ b/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt @@ -860,8 +860,12 @@ class BluetoothCentralManager(private val context: Context) { private fun startDisconnectionTimer() { cancelDisconnectionTimer() disconnectRunnable = Runnable { - Logger.e(TAG, "bluetooth turned off but no automatic disconnects happening, so doing it ourselves") - cancelAllConnectionsWhenBluetoothOff() + if (expectingBluetoothOffDisconnects) { + Logger.e(TAG, "bluetooth turned off but no automatic disconnects happening, so doing it ourselves") + cancelAllConnectionsWhenBluetoothOff() + } else { + Logger.e(TAG, "bluetooth turning on since manual disconnection timer has been launched, don't disconnect") + } disconnectRunnable = null } mainHandler.postDelayed(disconnectRunnable!!, 1000)