From 09632afb78c6796c5d4d05400c7d82eda3e611c0 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 20 Dec 2019 07:58:26 +0100 Subject: [PATCH] Huami: Fix stuck in connecting for most cases This happened when sending a notification while doing authentication. The reason the notification came though is the "auto connect" code that is supposed to connect when a message arrives, so that it does not get lost. This code and DeviceSupport::useAutoConnect() is probably totally useless by now and could be removed in favor of the "waiting for reconnect" state. The bug could have been solved by setting the device busy during authentication in Huami code, but I did it by... Note to self: "Block everything except a disconnect request in DeviceCommunicationService if the device is not yet initialzed but connected, assuming it is somewhere in the middle doing something important" --- .../gadgetbridge/service/DeviceCommunicationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 5066df6fc..a66528b49 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -287,7 +287,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere return START_NOT_STICKY; } - if (mDeviceSupport == null || (!isInitialized() && !mDeviceSupport.useAutoConnect())) { + if (mDeviceSupport == null || (!isInitialized() && !action.equals(ACTION_DISCONNECT) && (!mDeviceSupport.useAutoConnect() || isConnected()))) { // trying to send notification without valid Bluetooth connection if (mGBDevice != null) { // at least send back the current device state