1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

fido_u2f: properly close u2f layout when other layout starts

As it's currently impossible to close() the layout generator from the outside, loop.signal() was added, and any started layout signals to terminate.
This commit is contained in:
Jan Pochyla 2019-03-05 13:49:42 +01:00
parent 9b97b9e840
commit 3f0e3a334e
4 changed files with 12 additions and 2 deletions

View File

@ -353,7 +353,7 @@ class ConfirmState:
return False
return True
def setup(self, action: int, checksum: bytes, app_id: bytes) -> None:
def setup(self, action: int, checksum: bytes, app_id: bytes) -> bool:
if workflow.workflows:
return False
@ -379,6 +379,10 @@ class ConfirmState:
@ui.layout
async def confirm_layout(self) -> None:
workflow.fido_u2f_stop_signal.reset()
await loop.spawn(self.confirm_layout_inner(), workflow.fido_u2f_stop_signal)
async def confirm_layout_inner(self) -> None:
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
from trezor.ui.text import Text

View File

@ -16,7 +16,6 @@ from apps.wallet.sign_tx import (
)
@ui.layout
async def sign_tx(ctx, msg, keychain):
signer = signing.sign_tx(msg, keychain)

View File

@ -185,6 +185,9 @@ class signal(Syscall):
"""
def __init__(self):
self.reset()
def reset(self):
self.value = _NO_VALUE
self.task = None

View File

@ -5,6 +5,9 @@ layouts = []
default = None
default_layout = None
# HACK: workaround way to stop the u2f layout from the outside
fido_u2f_stop_signal = loop.signal()
def onstart(w):
workflows.append(w)
@ -44,6 +47,7 @@ def restartdefault():
def onlayoutstart(l):
closedefault()
layouts.append(l)
fido_u2f_stop_signal.send(None)
def onlayoutclose(l):