From d63db41f909204f55d2a2438d67c3b114d22dd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Tue, 9 Jan 2024 19:12:03 +0000 Subject: [PATCH] Huami: Display proper error when battery too low to install firmware --- .../huami/operations/UpdateFirmwareOperation2020.java | 5 +++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2020.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2020.java index 1db8b75e7..2ab9d6277 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2020.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2020.java @@ -55,6 +55,7 @@ public class UpdateFirmwareOperation2020 extends UpdateFirmwareOperation { public static final byte COMMAND_FINALIZE_UPDATE = (byte) 0xd6; public static final byte REPLY_ERROR_FREE_SPACE = (byte) 0x47; + public static final byte REPLY_ERROR_LOW_BATTERY = (byte) 0x22; protected int mChunkLength = -1; @@ -137,9 +138,13 @@ public class UpdateFirmwareOperation2020 extends UpdateFirmwareOperation { getSupport().logMessageContent(value); int errorMessage = R.string.updatefirmwareoperation_metadata_updateproblem; // Display a more specific error message for known errors + if (value[0] == HuamiService.RESPONSE && value[1] == COMMAND_START_TRANSFER && value[2] == REPLY_ERROR_FREE_SPACE) { // Not enough free space on the device errorMessage = R.string.updatefirmwareoperation_updateproblem_free_space; + } else if (value[0] == HuamiService.RESPONSE && value[1] == COMMAND_SEND_FIRMWARE_INFO && value[2] == REPLY_ERROR_LOW_BATTERY) { + // Battery is too low + errorMessage = R.string.updatefirmwareoperation_updateproblem_low_battery; } displayMessage(getContext(), getContext().getString(errorMessage), Toast.LENGTH_LONG, GB.ERROR); done(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c91041c58..df1cafc7a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -858,6 +858,7 @@ Problem with the firmware transfer. DO NOT REBOOT your Mi Band! Problem with the firmware metadata transfer The device does not have enough free space + The device battery is too low Firmware installation complete Firmware installation complete, rebooting deviceā€¦ Firmware flashing failed