Mi1/Mi2: fix firmware file probing for the different devices

here
cpfeiffer 2016-12-11 21:57:20 +01:00
parent bb5791485c
commit bcfc8bc110
2 changed files with 5 additions and 2 deletions

View File

@ -56,6 +56,9 @@ public class MiBand2FWHelper extends AbstractMiBandFWHelper {
@Override
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) {
firmwareInfo = new Mi2FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Mi Band 2 firmware");
}
}
@Override

View File

@ -57,8 +57,8 @@ public class Mi2FirmwareInfo {
return isHeaderValid() && device.getType() == DeviceType.MIBAND2;
}
protected boolean isHeaderValid() {
// TODO: not sure if this is a correct check!
public boolean isHeaderValid() {
// 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);
}