From b43d87f6bcbc2f9522706518572b2d27b59e4f4d Mon Sep 17 00:00:00 2001 From: "Martin.JM" Date: Mon, 3 Jun 2024 11:04:27 +0200 Subject: [PATCH] Huawei: Weather no longer depends on weather start response --- .../devices/huawei/HuaweiSupportProvider.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java index b05fce1b8..a978917dc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java @@ -1838,18 +1838,32 @@ public class HuaweiSupportProvider { Weather.Settings weatherSettings = new Weather.Settings(); SendWeatherStartRequest weatherStartRequest = new SendWeatherStartRequest(this, weatherSettings); - Request lastRequest = weatherStartRequest; + try { + weatherStartRequest.doPerform(); + } catch (IOException e) { + // TODO: Use translatable string + GB.toast(context, "Failed to send start weather", Toast.LENGTH_SHORT, GB.ERROR, e); + LOG.error("Failed to send start weather", e); + } + + Request firstRequest = null; + Request lastRequest = null; if (getHuaweiCoordinator().supportsWeatherUnit()) { SendWeatherUnitRequest weatherUnitRequest = new SendWeatherUnitRequest(this); - lastRequest.nextRequest(weatherUnitRequest); + firstRequest = weatherUnitRequest; lastRequest = weatherUnitRequest; } SendWeatherSupportRequest weatherSupportRequest = new SendWeatherSupportRequest(this, weatherSettings); - lastRequest.nextRequest(weatherSupportRequest); + if (firstRequest == null) { + firstRequest = weatherSupportRequest; + } else { + lastRequest.nextRequest(weatherSupportRequest); + } lastRequest = weatherSupportRequest; + if (getHuaweiCoordinator().supportsWeatherExtended()) { SendWeatherExtendedSupportRequest weatherExtendedSupportRequest = new SendWeatherExtendedSupportRequest(this, weatherSettings); lastRequest.nextRequest(weatherExtendedSupportRequest); @@ -1879,7 +1893,7 @@ public class HuaweiSupportProvider { } try { - weatherStartRequest.doPerform(); + firstRequest.doPerform(); } catch (IOException e) { // TODO: Use translatable string GB.toast(context, "Failed to send weather", Toast.LENGTH_SHORT, GB.ERROR, e);