src/apps/common: use ui.layout, clear display when layout starts

pull/25/head
Jan Pochyla 6 years ago
parent 031d20b25f
commit 54128b7568

@ -14,14 +14,12 @@ async def confirm(ctx, content, code=None, *args, **kwargs):
from trezor.messages.ButtonRequestType import Other
from trezor.messages.wire_types import ButtonAck
ui.display.clear()
dialog = ConfirmDialog(content, *args, **kwargs)
dialog.render()
if code is None:
code = Other
await ctx.call(ButtonRequest(code=code), ButtonAck)
dialog = ConfirmDialog(content, *args, **kwargs)
if __debug__:
waiter = loop.wait(signal, dialog)
else:
@ -36,14 +34,12 @@ async def hold_to_confirm(ctx, content, code=None, *args, **kwargs):
from trezor.messages.ButtonRequestType import Other
from trezor.messages.wire_types import ButtonAck
ui.display.clear()
dialog = HoldToConfirmDialog(content, 'Hold to confirm', *args, **kwargs)
if code is None:
code = Other
await ctx.call(ButtonRequest(code=code), ButtonAck)
dialog = HoldToConfirmDialog(content, 'Hold to confirm', *args, **kwargs)
if __debug__:
waiter = loop.wait(signal, dialog)
else:

@ -10,8 +10,8 @@ from apps.common import storage
from apps.common.cache import get_state
@ui.layout
async def request_passphrase_entry(ctx):
ui.display.clear()
text = Text(
'Enter passphrase', ui.ICON_RESET,
'Where to enter your', 'passphrase?')
@ -27,11 +27,9 @@ async def request_passphrase_entry(ctx):
return await EntrySelector(text)
async def request_passphrase(ctx):
on_device = await request_passphrase_entry(ctx) == DEVICE
@ui.layout
async def request_passphrase_ack(ctx, on_device):
if not on_device:
ui.display.clear()
text = Text(
'Passphrase entry', ui.ICON_RESET,
'Please, type passphrase', 'on connected host.')
@ -53,10 +51,15 @@ async def request_passphrase(ctx):
raise wire.FailureError(ProcessError, 'Passphrase not provided')
passphrase = ack.passphrase
if ack.state is not None:
if ack.state != get_state(salt=ack.state[:32], passphrase=passphrase):
raise wire.FailureError(ProcessError, 'Passphrase mismatch')
return ack.state, passphrase
async def request_passphrase(ctx):
on_device = await request_passphrase_entry(ctx) == DEVICE
state, passphrase = await request_passphrase_ack(ctx, on_device)
if state is not None:
if state != get_state(salt=state[:32], passphrase=passphrase):
raise wire.FailureError(ProcessError, 'Passphrase mismatch')
return passphrase

@ -30,7 +30,6 @@ async def request_pin(code: int = None, cancellable: bool = True) -> str:
c.taint()
c.render()
ui.display.clear()
matrix = PinMatrix(label, with_zero=True)
matrix.onchange = onchange
dialog = ConfirmDialog(matrix)

@ -113,6 +113,7 @@ def layout(f):
layout = f(*args, **kwargs)
workflow.onlayoutstart(layout)
loop.schedule(slide)
display.clear()
return await layout
finally:
loop.close(slide)

Loading…
Cancel
Save