feat(core): show confirmation dialog before rebooting

pull/2314/head
matejcik 2 years ago committed by matejcik
parent 60db3e3e52
commit e66ed079b0

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

Loading…
Cancel
Save