mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 03:16:51 +01:00
Amazfit Bip: support flashing new res, font, and latin font files
Required for firmware 0.1.0.66
This commit is contained in:
parent
f03a3c1f3b
commit
14a6c9a626
@ -47,6 +47,7 @@ public abstract class HuamiFWHelper extends AbstractMiBandFWHelper {
|
||||
int resId = R.string.kind_invalid;
|
||||
switch (getFirmwareInfo().getFirmwareType()) {
|
||||
case FONT:
|
||||
case FONT_LATIN:
|
||||
resId = R.string.kind_font;
|
||||
break;
|
||||
case GPS:
|
||||
|
@ -116,7 +116,7 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
|
||||
|
||||
@Override
|
||||
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
|
||||
if (ArrayUtils.startsWith(bytes, RES_HEADER)) {
|
||||
if (ArrayUtils.startsWith(bytes, RES_HEADER) || ArrayUtils.startsWith(bytes, NEWRES_HEADER)) {
|
||||
if (bytes.length > 500000) { // dont know how to distinguish from Cor .res
|
||||
return HuamiFirmwareType.INVALID;
|
||||
}
|
||||
@ -138,6 +138,12 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
|
||||
if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER)) {
|
||||
return HuamiFirmwareType.WATCHFACE;
|
||||
}
|
||||
if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) {
|
||||
if (bytes.length > 800000) {
|
||||
return HuamiFirmwareType.FONT;
|
||||
}
|
||||
return HuamiFirmwareType.FONT_LATIN;
|
||||
}
|
||||
return HuamiFirmwareType.INVALID;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,10 @@ public abstract class HuamiFirmwareInfo {
|
||||
0x48, 0x4d, 0x52, 0x45, 0x53
|
||||
};
|
||||
|
||||
protected static final byte[] NEWRES_HEADER = new byte[]{ // NERES resources file (*.res)
|
||||
0x4e, 0x45, 0x52, 0x45, 0x53
|
||||
};
|
||||
|
||||
protected static final byte[] WATCHFACE_HEADER = new byte[]{
|
||||
0x48, 0x4d, 0x44, 0x49, 0x41, 0x4c
|
||||
};
|
||||
@ -40,19 +44,31 @@ public abstract class HuamiFirmwareInfo {
|
||||
0x48, 0x4d, 0x5a, 0x4b
|
||||
};
|
||||
|
||||
protected static final byte[] NEWFT_HEADER = new byte[]{ // NEZK font file (*.ft, *.ft.xx)
|
||||
0x4e, 0x45, 0x5a, 0x4b
|
||||
};
|
||||
|
||||
private HuamiFirmwareType firmwareType = HuamiFirmwareType.FIRMWARE;
|
||||
|
||||
public String toVersion(int crc16) {
|
||||
String version = getCrcMap().get(crc16);
|
||||
if (version == null) {
|
||||
if (firmwareType == HuamiFirmwareType.FIRMWARE) {
|
||||
version = searchFirmwareVersion(bytes);
|
||||
}
|
||||
else if (firmwareType == HuamiFirmwareType.RES) {
|
||||
version = "RES " + Integer.toString(bytes[5]);
|
||||
}
|
||||
else if (firmwareType == HuamiFirmwareType.RES_NEW) {
|
||||
version = "RES " + Integer.toString(bytes[14]);
|
||||
switch (firmwareType) {
|
||||
case FIRMWARE:
|
||||
version = searchFirmwareVersion(bytes);
|
||||
break;
|
||||
case RES:
|
||||
version = "RES " + Integer.toString(bytes[5]);
|
||||
break;
|
||||
case RES_NEW:
|
||||
version = "RES " + Integer.toString(bytes[14]);
|
||||
break;
|
||||
case FONT:
|
||||
version = "FONT " + Integer.toString(bytes[4]);
|
||||
break;
|
||||
case FONT_LATIN:
|
||||
version = "FONT LATIN " + Integer.toString(bytes[4]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (version == null) {
|
||||
@ -61,6 +77,7 @@ public abstract class HuamiFirmwareInfo {
|
||||
version = "(unknown)";
|
||||
break;
|
||||
case FONT:
|
||||
case FONT_LATIN:
|
||||
version = "(unknown font)";
|
||||
break;
|
||||
case GPS:
|
||||
|
@ -25,6 +25,7 @@ public enum HuamiFirmwareType {
|
||||
GPS_CEP((byte) 4),
|
||||
GPS_ALMANAC((byte)5),
|
||||
WATCHFACE((byte)8),
|
||||
FONT_LATIN((byte)11),
|
||||
INVALID(Byte.MIN_VALUE);
|
||||
|
||||
private final byte value;
|
||||
|
Loading…
Reference in New Issue
Block a user