1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

fix(core): streamline progress animation disabling

This commit is contained in:
matejcik 2022-05-03 13:59:01 +02:00 committed by Martin Milata
parent ee694f36cf
commit e47bcee4a4
2 changed files with 11 additions and 13 deletions

View File

@ -23,12 +23,12 @@ async def get_firmware(ctx: Context, _msg: GetFirmware) -> Success:
action="Do you want to extract device firmware?",
description="Your seed will not be revealed.",
)
if not utils.DISABLE_ANIMATION:
workflow.close_others()
draw_simple_text("Please wait")
sector_buffer = bytearray(CHUNK_SIZE)
packet = FirmwareChunk(chunk=sector_buffer)
workflow.close_others()
draw_simple_text("Please wait")
progress = 0
_render_progress(progress, PROGRESS_TOTAL)
for i in range(utils.FIRMWARE_SECTORS_COUNT):

View File

@ -10,14 +10,11 @@ if TYPE_CHECKING:
async def get_firmware_hash(ctx: Context, msg: GetFirmwareHash) -> FirmwareHash:
render_func = None
if not DISABLE_ANIMATION:
workflow.close_others()
draw_simple_text("Please wait")
render_func = _render_progress
workflow.close_others()
draw_simple_text("Please wait")
try:
hash = firmware_hash(msg.challenge, render_func)
hash = firmware_hash(msg.challenge, _render_progress)
except ValueError as e:
raise wire.DataError(str(e))
@ -25,6 +22,7 @@ async def get_firmware_hash(ctx: Context, msg: GetFirmwareHash) -> FirmwareHash:
def _render_progress(progress: int, total: int) -> None:
p = 1000 * progress // total
ui.display.loader(p, False, 18, ui.WHITE, ui.BG)
ui.refresh()
if not DISABLE_ANIMATION:
p = 1000 * progress // total
ui.display.loader(p, False, 18, ui.WHITE, ui.BG)
ui.refresh()