diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/Mi1SFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/Mi1SFirmwareInfo.java index 1447559e..32193d33 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/Mi1SFirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/Mi1SFirmwareInfo.java @@ -46,9 +46,15 @@ public class Mi1SFirmwareInfo extends AbstractMi1SFirmwareInfo { return false; } try { - return fw1Info.isGenerallySupportedFirmware() && fw2Info.isGenerallySupportedFirmware(); + return fw1Info.isGenerallySupportedFirmware() + && fw2Info.isGenerallySupportedFirmware() + && fw1Info.getFirmwareBytes().length > 0 + && fw2Info.getFirmwareBytes().length > 0; } catch (IndexOutOfBoundsException ex) { return false; + } catch (IllegalArgumentException ex) { + LOG.warn("not supported 1S firmware: ", ex); + return false; } } diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/FirmwareTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/FirmwareTest.java index 0c7471a3..732464f6 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/FirmwareTest.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/FirmwareTest.java @@ -33,6 +33,7 @@ public class FirmwareTest { int calculatedVersion = info.getFirmwareVersion(); String version = MiBandFWHelper.formatFirmwareVersion(calculatedVersion); Assert.assertTrue(version.startsWith("1.")); + Assert.assertArrayEquals(wholeFw, info.getFirmwareBytes()); // Assert.assertEquals("Unexpected firmware version: " + calculatedVersion, MI_FW_VERSION, calculatedVersion); } @@ -45,6 +46,7 @@ public class FirmwareTest { int calculatedVersion = info.getFirmwareVersion(); String version = MiBandFWHelper.formatFirmwareVersion(calculatedVersion); Assert.assertTrue(version.startsWith("5.")); + Assert.assertArrayEquals(wholeFw, info.getFirmwareBytes()); // Assert.assertEquals("Unexpected firmware version: " + calculatedVersion, MI1A_FW_VERSION, calculatedVersion); }