1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 06:18:07 +00:00

feat(core): show confirmation dialog before rebooting

This commit is contained in:
matejcik 2022-05-31 13:19:44 +02:00 committed by matejcik
parent 60db3e3e52
commit e66ed079b0

View File

@ -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