Huami: Display proper error when battery too low to install firmware

This commit is contained in:
José Rebelo 2024-01-09 19:12:03 +00:00
parent b4b4d3eb58
commit d63db41f90
2 changed files with 6 additions and 0 deletions

View File

@ -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();

View File

@ -858,6 +858,7 @@
<string name="updatefirmwareoperation_updateproblem_do_not_reboot">Problem with the firmware transfer. DO NOT REBOOT your Mi Band!</string>
<string name="updatefirmwareoperation_metadata_updateproblem">Problem with the firmware metadata transfer</string>
<string name="updatefirmwareoperation_updateproblem_free_space">The device does not have enough free space</string>
<string name="updatefirmwareoperation_updateproblem_low_battery">The device battery is too low</string>
<string name="updatefirmwareoperation_update_complete">Firmware installation complete</string>
<string name="updatefirmwareoperation_update_complete_rebooting">Firmware installation complete, rebooting device…</string>
<string name="updatefirmwareoperation_write_failed">Firmware flashing failed</string>