1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 11:35:48 +01:00

Mi Band 3: Allow flashing fonts (untested)

This commit is contained in:
Andreas Shimokawa 2018-07-01 22:41:37 +02:00
parent 9303214997
commit d1cba54425
3 changed files with 13 additions and 2 deletions

View File

@ -48,6 +48,8 @@ public abstract class HuamiFirmwareInfo {
0x4e, 0x45, 0x5a, 0x4b
};
protected static final int FONT_TYPE_OFFSET = 0x9;
private HuamiFirmwareType firmwareType = HuamiFirmwareType.FIRMWARE;
public String toVersion(int crc16) {

View File

@ -78,8 +78,11 @@ public class Mi2FirmwareInfo extends HuamiFirmwareInfo {
}
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.startsWith(bytes, HuamiFirmwareInfo.FT_HEADER)) {
return HuamiFirmwareType.FONT;
if (ArrayUtils.startsWith(bytes, FT_HEADER)) {
if (bytes[FONT_TYPE_OFFSET] == 0x00 || bytes[FONT_TYPE_OFFSET] == (byte) 0xff) {
return HuamiFirmwareType.FONT;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.equals(bytes, FW_HEADER, FW_HEADER_OFFSET)
&& (bytes[FW_MAGIC_OFFSET] == FW_MAGIC)) {

View File

@ -53,6 +53,12 @@ public class MiBand3FirmwareInfo extends HuamiFirmwareInfo {
@Override
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.startsWith(bytes, FT_HEADER)) {
if (bytes[FONT_TYPE_OFFSET] == 0x03 || bytes[FONT_TYPE_OFFSET] == 0x04) {
return HuamiFirmwareType.FONT;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, RES_HEADER)) {
if (bytes.length > 100000) { // don't know how to distinguish from Bip/Cor .res
return HuamiFirmwareType.INVALID;