From 6b8787c98475239fc81d93c09dcc7c8e8ac3567d Mon Sep 17 00:00:00 2001 From: Richard Dennehy Date: Sat, 11 May 2024 15:02:53 +0100 Subject: [PATCH] fix bluetooth device disconnection not being correctly detected --- .../eveningoutpost/dexdrip/utils/HeadsetStateReceiver.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utils/HeadsetStateReceiver.java b/app/src/main/java/com/eveningoutpost/dexdrip/utils/HeadsetStateReceiver.java index 84eaa0eaca..d735138529 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utils/HeadsetStateReceiver.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utils/HeadsetStateReceiver.java @@ -44,18 +44,16 @@ public void onReceive(Context context, Intent intent) { final int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, -1); final int previousState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, -1); final String deviceInfo = device.getName() + "\n" + device.getAddress() + " " + (device.getBluetoothClass() != null ? device.getBluetoothClass() : ""); - //UserError.Log.uel(TAG, "Bluetooth audio connection state change: " + state + " was " + previousState + " " + device.getAddress() + " " + device.getName()); + // UserError.Log.uel(TAG, "Bluetooth audio connection state change: from " + previousState + " to " + state + " " + device.getAddress() + " " + device.getName()); if (state == BluetoothProfile.STATE_CONNECTED && previousState != BluetoothProfile.STATE_CONNECTED) { PersistentStore.setString(PREF_LAST_CONNECTED_MAC, device.getAddress()); PersistentStore.setString(PREF_LAST_CONNECTED_NAME, device.getName()); UserError.Log.uel(TAG, "Bluetooth Audio connected: " + deviceInfo); processDevice(device.getAddress(), true); - - } else if (state == BluetoothProfile.STATE_DISCONNECTED && previousState == BluetoothProfile.STATE_CONNECTED) { + } else if (state == BluetoothProfile.STATE_DISCONNECTED && previousState != BluetoothProfile.STATE_DISCONNECTED) { UserError.Log.uel(TAG, "Bluetooth Audio disconnected: " + deviceInfo); processDevice(device.getAddress(), false); } - } else { UserError.Log.d(TAG, "Device was null in intent!"); }