1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-29 16:26:18 +02:00

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"
This commit is contained in:
Andreas Shimokawa 2019-12-20 07:58:26 +01:00
parent f28b4e6edc
commit 09632afb78

View File

@ -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