1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 19:45:50 +01:00

Amazfit GTR: FIx firmware flashing on newer firmares

This commit is contained in:
Andreas Shimokawa 2020-11-12 17:28:19 +01:00
parent 447e9110db
commit c3b8604338

View File

@ -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;
}
}