From c3b8604338562a84b2486fb3a9ff9e0f251cbdc9 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 12 Nov 2020 17:28:19 +0100 Subject: [PATCH] Amazfit GTR: FIx firmware flashing on newer firmares --- .../huami/amazfitgtr/AmazfitGTRSupport.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRSupport.java index f165df824..f19456b5b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr/AmazfitGTRSupport.java @@ -24,6 +24,9 @@ import java.io.IOException; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRFWHelper; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperationNew; import nodomain.freeyourgadget.gadgetbridge.util.Version; public class AmazfitGTRSupport extends AmazfitGTSSupport { @@ -33,15 +36,29 @@ public class AmazfitGTRSupport extends AmazfitGTSSupport { return new AmazfitGTRFWHelper(uri, context); } + @Override + public UpdateFirmwareOperation createUpdateFirmwareOperation(Uri uri) { + Version version = new Version(gbDevice.getFirmwareVersion()); + if (version.compareTo(new Version("1.3.7.16")) >= 0) { + return new UpdateFirmwareOperation2020(uri, this); + } + + return new UpdateFirmwareOperationNew(uri, this); + } + @Override protected void handleDeviceInfo(nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo info) { super.handleDeviceInfo(info); if (gbDevice.getFirmwareVersion() != null) { Version version = new Version(gbDevice.getFirmwareVersion()); if (version.compareTo(new Version("1.3.5.79")) >= 0 || // For GTR 47mm - (version.compareTo(new Version("1.0.0.00")) < 0 && version.compareTo(new Version("0.1.1.15")) >= 0)) { // for GTR 32mm with a different version scheme + (!is47mm(version) && version.compareTo(new Version("0.1.1.15")) >= 0)) { // for GTR 32mm with a different version scheme mActivitySampleSize = 8; } } } + + private boolean is47mm(Version version) { + return version.compareTo(new Version("1.0.0.00")) >= 0; + } }