1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Device connection: consider WAITING_FOR_SCAN as reconnecting state

This commit is contained in:
Daniel Dakhno 2024-02-26 00:44:47 +01:00
parent 07744331ac
commit 7219bd377b

View File

@ -1133,15 +1133,21 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
return false;
}
private boolean isDeviceReconnecting(GBDevice device) {
for(DeviceStruct struct : deviceStructs){
if(struct.getDevice().getAddress().compareToIgnoreCase(device.getAddress()) == 0){
return struct.getDevice().getStateOrdinal() == GBDevice.State.WAITING_FOR_RECONNECT.ordinal();
private boolean deviceStateEquals(GBDevice device, GBDevice.State... states){
if((device = getDeviceByAddressOrNull(device.getAddress())) != null){
for(GBDevice.State possibleState : states){
if(device.getState() == possibleState){
return true;
}
}
}
return false;
}
private boolean isDeviceReconnecting(GBDevice device) {
return deviceStateEquals(device, GBDevice.State.WAITING_FOR_RECONNECT, GBDevice.State.WAITING_FOR_SCAN);
}
private boolean deviceHasCalendarReceiverRegistered(GBDevice device){
for (CalendarReceiver receiver: mCalendarReceiver){
if(receiver.getGBDevice().equals(device)){