diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband2/MiBand2FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband2/MiBand2FWHelper.java index a4beb56d..207aceef 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband2/MiBand2FWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband2/MiBand2FWHelper.java @@ -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 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2FirmwareInfo.java index c0bb6717..6e9cb0a0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2FirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2FirmwareInfo.java @@ -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); }