1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-09 03:37:03 +01:00

Huawei: Init chain issues for some devices fixed. Timeout increased

This commit is contained in:
Me7c7 2024-09-29 13:08:01 +03:00
parent e070569ab5
commit 3fe3f9698a
2 changed files with 24 additions and 25 deletions

View File

@ -173,7 +173,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class HuaweiSupportProvider {
private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class);
private final int initTimeout = 1000;
private final int initTimeout = 2000;
private HuaweiBRSupport brSupport;
private HuaweiLESupport leSupport;
@ -614,7 +614,6 @@ public class HuaweiSupportProvider {
initRequestQueue.add(new GetProductInformationRequest(this));
initRequestQueue.add(new SetTimeRequest(this, true));
initRequestQueue.add(batteryLevelReq);
initRequestQueue.add(new SendFitnessUserInfoRequest(this));
initRequestQueue.add(new GetSupportedServicesRequest(this)); // MUST BE LAST - it indirectly kicks off initializeDynamicServices
// Queue all the requests
@ -752,6 +751,7 @@ public class HuaweiSupportProvider {
initRequestQueue.add(new SendMenstrualCapabilityRequest(this));
initRequestQueue.add(new SendNotifyHeartRateCapabilityRequest(this));
initRequestQueue.add(new SendNotifyRestHeartRateCapabilityRequest(this));
initRequestQueue.add(new SendFitnessUserInfoRequest(this));
initRequestQueue.add(new SendRunPaceConfigRequest(this));
initRequestQueue.add(new SendDeviceReportThreshold(this));
initRequestQueue.add(new SetMediumToStrengthThresholdRequest(this));
@ -782,6 +782,10 @@ public class HuaweiSupportProvider {
// Queue all the requests
for (int i = 1; i < initRequestQueue.size(); i++) {
initRequestQueue.get(i - 1).setupTimeoutUntilNext(initTimeout);
if(initRequestQueue.get(i - 1) instanceof SendSetUpDeviceStatusRequest) {
// NOTE: The watch is never answer to this command. To decrease init time timeout for it is 50 ms
initRequestQueue.get(i - 1).setupTimeoutUntilNext(50);
}
initRequestQueue.get(i - 1).nextRequest(initRequestQueue.get(i));
}

View File

@ -133,6 +133,16 @@ public class Request {
}
}
private Runnable getTimeoutRunnable() {
return () -> {
LOG.debug("Timeout on Service {} command {}", Integer.toHexString(this.serviceId & 0xff), Integer.toHexString(this.commandId & 0xff));
if (finalizeReq != null)
finalizeReq.timeout(this);
else
this.handleNext();
};
}
public Request(HuaweiSupportProvider supportProvider, nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder builder) {
this.supportProvider = supportProvider;
this.paramsProvider = supportProvider.getParamsProvider();
@ -142,13 +152,7 @@ public class Request {
this.isSelfQueue = true;
this.handler = new Handler(Looper.getMainLooper());
this.timeoutRunner = () -> {
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
if (finalizeReq != null)
finalizeReq.timeout(this);
else
this.handleNext();
};
this.timeoutRunner = getTimeoutRunnable();
}
public Request(HuaweiSupportProvider supportProvider, nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder builder) {
@ -160,13 +164,7 @@ public class Request {
this.isSelfQueue = true;
this.handler = new Handler(Looper.getMainLooper());
this.timeoutRunner = () -> {
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
if (finalizeReq != null)
finalizeReq.timeout(this);
else
this.handleNext();
};
this.timeoutRunner = getTimeoutRunnable();
}
public Request(HuaweiSupportProvider supportProvider) {
@ -181,13 +179,7 @@ public class Request {
this.isSelfQueue = true;
this.handler = new Handler(Looper.getMainLooper());
this.timeoutRunner = () -> {
LOG.debug("Timeout on Service {} command {}", this.serviceId, this.commandId);
if (finalizeReq != null)
finalizeReq.timeout(this);
else
this.handleNext();
};
this.timeoutRunner = getTimeoutRunnable();
}
protected boolean requestSupported() {
@ -275,6 +267,7 @@ public class Request {
finalizeReq.call(this);
}
}
nextRequest = null;
}
public void setSelfQueue() {
@ -282,8 +275,10 @@ public class Request {
}
public Request nextRequest(Request req) {
nextRequest = req;
nextRequest.setSelfQueue();
if (req != null) {
nextRequest = req;
nextRequest.setSelfQueue();
}
return this;
}