From 86460ea7c6d24dc373e7b031adb277ab5dea57d8 Mon Sep 17 00:00:00 2001 From: ~noodlez1232 Date: Fri, 13 Sep 2024 16:44:44 -0700 Subject: [PATCH] AsteroidOS: Fix the weather service + set-time The weather service was suffering from an off-by-one error. This is now fixed. The weather also sends more days in its forecast. There is an issue open in the AsteroidOS weather app to perhaps add more days to its forcast so this should cover for it. There is also a fix for the time not being set upon connection. I'm not quite sure why this wasn't happening before, but it is happening now. It might be a bit kludgy, but it is what it is. --- .../devices/asteroidos/AsteroidOSWeather.java | 9 +++++---- .../devices/asteroidos/AsteroidOSDeviceSupport.java | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/asteroidos/AsteroidOSWeather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/asteroidos/AsteroidOSWeather.java index a07cdcfd9..655b0d847 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/asteroidos/AsteroidOSWeather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/asteroidos/AsteroidOSWeather.java @@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.devices.asteroidos; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; @@ -67,7 +68,7 @@ public class AsteroidOSWeather { /** * The days of the weather */ - public Day[] days = new Day[5]; + public ArrayList days = new ArrayList<>(); /** * The city name of the weather */ @@ -80,9 +81,9 @@ public class AsteroidOSWeather { */ public AsteroidOSWeather(WeatherSpec spec) { cityName = spec.location; - days[0] = new Day(spec); - for (int i = 1; i < 5 && i < spec.forecasts.size(); i++) { - days[i] = new Day(spec.forecasts.get(i)); + days.add(new Day(spec)); + for (int i = 1; i < spec.forecasts.size(); i++) { + days.add(new Day(spec.forecasts.get(i - 1))); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/asteroidos/AsteroidOSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/asteroidos/AsteroidOSDeviceSupport.java index 33c1f7d35..bae9b9eb8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/asteroidos/AsteroidOSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/asteroidos/AsteroidOSDeviceSupport.java @@ -52,6 +52,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.IntentListener; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.battery.BatteryInfoProfile; +import nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetTimeRequest; public class AsteroidOSDeviceSupport extends AbstractBTLEDeviceSupport { private static final Logger LOG = LoggerFactory.getLogger(AsteroidOSDeviceSupport.class); @@ -112,6 +113,8 @@ public class AsteroidOSDeviceSupport extends AbstractBTLEDeviceSupport { batteryInfoProfile.requestBatteryInfo(builder); batteryInfoProfile.enableNotify(builder, true); + // Gadgetbridge doesn't seem to do this itself, so we force it to set its time + onSetTime(); return builder; }