Huawei: Allow getting alarm list retrieval to fail

For #6054
This commit is contained in:
Martin.JM
2026-05-11 21:42:31 +02:00
parent 8a8b811acf
commit 698b4b4642
3 changed files with 25 additions and 5 deletions
@@ -947,6 +947,14 @@ public class HuaweiSupportProvider {
if (!getDeviceState().supportsChangingAlarm() && firstConnection)
initializeAlarms();
RequestCallback allowFailFinalize = new RequestCallback() {
@Override
public void handleException(Request request, Request.ResponseParseException e) {
LOG.info("Exception on init request {} allowed", request, e);
request.handleNext();
}
};
// Queue all the requests
for (int i = 1; i < initRequestQueue.size(); i++) {
initRequestQueue.get(i - 1).setupTimeoutUntilNext(initTimeout);
@@ -954,6 +962,13 @@ public class HuaweiSupportProvider {
// 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);
}
if (
initRequestQueue.get(i - 1) instanceof GetEventAlarmList ||
initRequestQueue.get(i - 1) instanceof GetSmartAlarmList
) {
// NOTE: Some watches fail to properly respond to this, but this should still allow the connection to complete
initRequestQueue.get(i - 1).setFinalizeReq(allowFailFinalize);
}
initRequestQueue.get(i - 1).nextRequest(initRequestQueue.get(i));
}
@@ -121,13 +121,18 @@ public class Request {
public RequestCallback(HuaweiSupportProvider supportProvider) {
support = supportProvider;
}
@Deprecated
public void call() {}
public void call(Request request) {
call(); // To keep everything working as it was as well
}
@Deprecated
public void handleException(ResponseParseException e) {
LOG.error("Callback request exception", e);
}
public void handleException(Request request, ResponseParseException e) {
handleException(e); // To keep everything working as it was as well
}
public void timeout(Request request) {
request.handleNext();
}
@@ -243,14 +248,14 @@ public class Request {
} catch (HuaweiPacket.ParseException e) {
LOG.error("Parse TLV exception", e);
if (finalizeReq != null)
finalizeReq.handleException(new ResponseParseException("Parse TLV exception", e));
finalizeReq.handleException(this, new ResponseParseException("Parse TLV exception", e));
return;
}
try {
processResponse();
} catch (ResponseParseException e) {
if (finalizeReq != null)
finalizeReq.handleException(e);
finalizeReq.handleException(this, e);
return;
}
handleNext();
@@ -264,7 +269,7 @@ public class Request {
GB.toast(supportProvider.getContext(), "nextRequest failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Next request failed", e);
if (finalizeReq != null)
finalizeReq.handleException(new ResponseParseException("Next request failed", e));
finalizeReq.handleException(this, new ResponseParseException("Next request failed", e));
return;
}
}
@@ -94,7 +94,7 @@ public class RequestBuilder<T extends HuaweiPacket> {
//noinspection unchecked
onCallback.callback((T) request.receivedPacket);
} catch (ClassCastException e) {
handleException(new GenericTypeException(serviceId, commandId, e));
handleException(request, new GenericTypeException(serviceId, commandId, e));
}
}
@@ -107,7 +107,7 @@ public class RequestBuilder<T extends HuaweiPacket> {
//noinspection unchecked
onTimeout.timeout((T) request.receivedPacket);
} catch (ClassCastException e) {
handleException(new GenericTypeException(serviceId, commandId, e));
handleException(request, new GenericTypeException(serviceId, commandId, e));
}
}