From 94cfaadc41572bd7f6918436ea42636b9f52ed17 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 25 Oct 2017 22:26:38 +0200 Subject: [PATCH] Amazfit Cor: whitelist latest .res and .fw Add a note about this being totally untested, especially scary since the new res format is different. --- .../devices/huami/amazfitcor/AmazfitCorFirmwareInfo.java | 6 ++++++ app/src/main/res/values/strings.xml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcor/AmazfitCorFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcor/AmazfitCorFirmwareInfo.java index 41ad891bf..694867dac 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcor/AmazfitCorFirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcor/AmazfitCorFirmwareInfo.java @@ -33,15 +33,19 @@ public class AmazfitCorFirmwareInfo extends HuamiFirmwareInfo { }; private static final int FW_HEADER_OFFSET = 0x9330; + private static final int NEW_RES_HEADER_OFFSET = 0x9; private static Map crcToVersion = new HashMap<>(); static { // firmware crcToVersion.put(39948, "1.0.5.60"); + crcToVersion.put(62147, "1.0.5.78"); // resources crcToVersion.put(46341, "RES 1.0.5.60"); + crcToVersion.put(21770, "RES 1.0.5.78"); + } public AmazfitCorFirmwareInfo(byte[] bytes) { @@ -55,6 +59,8 @@ public class AmazfitCorFirmwareInfo extends HuamiFirmwareInfo { return HuamiFirmwareType.INVALID; } return HuamiFirmwareType.RES; + } else if (ArrayUtils.equals(bytes, RES_HEADER, NEW_RES_HEADER_OFFSET)) { + return HuamiFirmwareType.RES; } else if (ArrayUtils.equals(bytes, FW_HEADER, FW_HEADER_OFFSET)) { // TODO: this is certainly not a correct validation, but it works for now return HuamiFirmwareType.FIRMWARE; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d62753284..2e2afe22a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -54,8 +54,8 @@ FW/App installer You are about to install firmware %s instead of the one currently on your Mi Band. - You are about to install firmware %s instead of the one currently on your Amazfit Bip.\n\nPlease make sure to install the .gps firmware, then the .res file, and finally the .fw file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res and .gps if these files are exactly the same as the ones previously installed.\n\nEXPERIMENTAL, PROCEED AT YOUR OWN RISK - You are about to install firmware %s instead of the one currently on your Amazfit Cor.\n\nPlease make sure to install the .res file, and after that the .fw file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nEXPERIMENTAL, PROCEED AT YOUR OWN RISK + You are about to install firmware %s on your Amazfit Bip.\n\nPlease make sure to install the .gps firmware, then the .res file, and finally the .fw file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res and .gps if these files are exactly the same as the ones previously installed.\n\nPROCEED AT YOUR OWN RISK! + You are about to install firmware %s on your Amazfit Cor.\n\nPlease make sure to install the .res file, and after that the .fw file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nUNTESTED, MAY BRICK YOUR DEVICE, PROCEED AT YOUR OWN RISK! You are about to install firmwares %1$s and %2$s instead of the ones currently on your Mi Band. This firmware has been tested and is known to be compatible with Gadgetbridge. "This firmware is untested and may not be compatible with Gadgetbridge.\n\nYou are NOT encouraged to flash it to your Mi Band!"