From 48e5f44b814a23fd0380b09e0190fedfd50e1198 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 1 Oct 2021 17:49:43 +0200 Subject: [PATCH] Amazfit Bip U Pro: Fix flashing firmware, res, font, watchfaces --- .../AmazfitBipUProFirmwareInfo.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProFirmwareInfo.java index a72eeac97..2c8c418f9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProFirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbipupro/AmazfitBipUProFirmwareInfo.java @@ -19,7 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipupr import java.util.HashMap; import java.util.Map; -import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo; @@ -42,37 +41,35 @@ public class AmazfitBipUProFirmwareInfo extends HuamiFirmwareInfo { @Override protected HuamiFirmwareType determineFirmwareType(byte[] bytes) { - GBDevice device = GBApplication.app().getDeviceManager().getSelectedDevice(); - if (ArrayUtils.equals(bytes, MiBand4FirmwareInfo.FW_HEADER, MiBand4FirmwareInfo.FW_HEADER_OFFSET)) { - if (searchString32BitAligned(bytes, "Amazfit Bip U Pro")) { + if (searchString32BitAligned(bytes, "\0\0Amazfit Bip U Pro")) { return HuamiFirmwareType.FIRMWARE; } return HuamiFirmwareType.INVALID; - } - if (ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET) || - ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET_NEW)) { - return HuamiFirmwareType.RES_COMPRESSED; + if (ArrayUtils.startsWith(bytes, NEWRES_HEADER)) { + return HuamiFirmwareType.RES; } - if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER)) { + if (ArrayUtils.startsWith(bytes, UIHH_HEADER) && (bytes[4] == 1 || bytes[4] == 2)) { return HuamiFirmwareType.WATCHFACE; } - if (ArrayUtils.startsWith(bytes, GPS_ALMANAC_HEADER)) { - return HuamiFirmwareType.GPS_ALMANAC; - } - if (ArrayUtils.startsWith(bytes, GPS_CEP_HEADER)) { - return HuamiFirmwareType.GPS_CEP; - } + if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) { if (bytes[10] == 0x01 || bytes[10] == 0x06 || bytes[10] == 0x03) { return HuamiFirmwareType.FONT; - } else if (bytes[10] == 0x02 || bytes[10] == 0x0A) { - return HuamiFirmwareType.FONT_LATIN; } } + + if (ArrayUtils.startsWith(bytes, GPS_ALMANAC_HEADER)) { + return HuamiFirmwareType.GPS_ALMANAC; + } + + if (ArrayUtils.startsWith(bytes, GPS_CEP_HEADER)) { + return HuamiFirmwareType.GPS_CEP; + } + for (byte[] gpsHeader : GPS_HEADERS) { if (ArrayUtils.startsWith(bytes, gpsHeader)) { return HuamiFirmwareType.GPS;