From e66ed079b0c451b9c50058d0c349ce6a324874cf Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 31 May 2022 13:19:44 +0200 Subject: [PATCH] feat(core): show confirmation dialog before rebooting --- .../src/apps/management/reboot_to_bootloader.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/apps/management/reboot_to_bootloader.py b/core/src/apps/management/reboot_to_bootloader.py index edd3ca744..94ea34e6c 100644 --- a/core/src/apps/management/reboot_to_bootloader.py +++ b/core/src/apps/management/reboot_to_bootloader.py @@ -1,7 +1,8 @@ from typing import TYPE_CHECKING -from trezor import utils, wire +from trezor import io, loop, utils, wire from trezor.messages import RebootToBootloader, Success +from trezor.ui.layouts import confirm_action if TYPE_CHECKING: from typing import NoReturn @@ -10,8 +11,16 @@ if TYPE_CHECKING: async def reboot_to_bootloader(ctx: wire.Context, msg: RebootToBootloader) -> NoReturn: - await ctx.write(Success()) - # writing synchronously twice makes USB flush properly before reboot - await ctx.write(Success()) + await confirm_action( + ctx, + "reboot", + "Go to bootloader", + "Do you want to restart Trezor in bootloader mode?", + hold_danger=True, + verb="Restart", + ) + await ctx.write(Success(message="Rebooting")) + # make sure the outgoing USB buffer is flushed + await loop.wait(ctx.iface.iface_num() | io.POLL_WRITE) utils.reboot_to_bootloader() raise RuntimeError