mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-10 03:59:24 +01:00
Mi1/Mi2: fix firmware file probing for the different devices
This commit is contained in:
parent
bb5791485c
commit
bcfc8bc110
@ -56,6 +56,9 @@ public class MiBand2FWHelper extends AbstractMiBandFWHelper {
|
|||||||
@Override
|
@Override
|
||||||
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) {
|
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) {
|
||||||
firmwareInfo = new Mi2FirmwareInfo(wholeFirmwareBytes);
|
firmwareInfo = new Mi2FirmwareInfo(wholeFirmwareBytes);
|
||||||
|
if (!firmwareInfo.isHeaderValid()) {
|
||||||
|
throw new IllegalArgumentException("Not a Mi Band 2 firmware");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,8 +57,8 @@ public class Mi2FirmwareInfo {
|
|||||||
return isHeaderValid() && device.getType() == DeviceType.MIBAND2;
|
return isHeaderValid() && device.getType() == DeviceType.MIBAND2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isHeaderValid() {
|
public boolean isHeaderValid() {
|
||||||
// TODO: not sure if this is a correct check!
|
// TODO: this is certainly not a correct validation, but it works for now
|
||||||
return ArrayUtils.equals(FW_HEADER, bytes, FW_HEADER_OFFSET, FW_HEADER_OFFSET + FW_HEADER.length);
|
return ArrayUtils.equals(FW_HEADER, bytes, FW_HEADER_OFFSET, FW_HEADER_OFFSET + FW_HEADER.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user