1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Device connection: classify more states as reconnecting

This commit is contained in:
Daniel Dakhno 2024-02-26 13:01:09 +01:00
parent a75b3afc84
commit ee1c3e4db9
2 changed files with 7 additions and 4 deletions

View File

@ -310,7 +310,7 @@ public class GBDevice implements Parcelable {
} }
public boolean isConnected() { public boolean isConnected() {
return mState.ordinal() >= State.CONNECTED.ordinal(); return mState.equalsOrHigherThan(State.CONNECTED);
} }
public boolean isInitializing() { public boolean isInitializing() {
@ -761,8 +761,8 @@ public class GBDevice implements Parcelable {
return simpleStringId; return simpleStringId;
} }
boolean equalsOrHigherThan(State otherState){ public boolean equalsOrHigherThan(State otherState){
return ordinal() >= otherState.ordinal(); return compareTo(otherState) >= 0;
} }
} }
} }

View File

@ -1145,7 +1145,10 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
} }
private boolean isDeviceReconnecting(GBDevice device) { private boolean isDeviceReconnecting(GBDevice device) {
return deviceStateEquals(device, GBDevice.State.WAITING_FOR_RECONNECT, GBDevice.State.WAITING_FOR_SCAN); if((device = getDeviceByAddressOrNull(device.getAddress())) != null){
return device.getState().equalsOrHigherThan(GBDevice.State.NOT_CONNECTED);
}
return false;
} }
private boolean deviceHasCalendarReceiverRegistered(GBDevice device){ private boolean deviceHasCalendarReceiverRegistered(GBDevice device){