fix(core): don't send button requests when unlocking because BLE pairing is in progress

[no changelog]
tychovrahe/bluetooth/master
tychovrahe 1 year ago
parent 46a517fa2e
commit 5a1bc2db85

@ -319,7 +319,9 @@ def lock_device_if_unlocked() -> None:
lock_device(interrupt_workflow=workflow.autolock_interrupts_workflow) lock_device(interrupt_workflow=workflow.autolock_interrupts_workflow)
async def unlock_device(ctx: wire.GenericContext = wire.DUMMY_CONTEXT) -> None: async def unlock_device(
ctx: wire.GenericContext = wire.DUMMY_CONTEXT, skip_button_request: bool = False
) -> None:
"""Ensure the device is in unlocked state. """Ensure the device is in unlocked state.
If the storage is locked, attempt to unlock it. Reset the homescreen and the wire If the storage is locked, attempt to unlock it. Reset the homescreen and the wire
@ -329,7 +331,7 @@ async def unlock_device(ctx: wire.GenericContext = wire.DUMMY_CONTEXT) -> None:
if not config.is_unlocked(): if not config.is_unlocked():
# verify_user_pin will raise if the PIN was invalid # verify_user_pin will raise if the PIN was invalid
await verify_user_pin(ctx) await verify_user_pin(ctx, skip_button_request=skip_button_request)
set_homescreen() set_homescreen()

@ -98,6 +98,7 @@ async def verify_user_pin(
allow_cancel: bool = True, allow_cancel: bool = True,
retry: bool = True, retry: bool = True,
cache_time_ms: int = 0, cache_time_ms: int = 0,
skip_button_request: bool = False,
) -> None: ) -> None:
# _get_last_unlock_time # _get_last_unlock_time
last_unlock = int.from_bytes( last_unlock = int.from_bytes(
@ -116,7 +117,11 @@ async def verify_user_pin(
from trezor.ui.layouts import request_pin_on_device from trezor.ui.layouts import request_pin_on_device
pin = await request_pin_on_device( pin = await request_pin_on_device(
ctx, prompt, config.get_pin_rem(), allow_cancel ctx,
prompt,
config.get_pin_rem(),
allow_cancel,
skip_button_request=skip_button_request,
) )
config.ensure_not_wipe_code(pin) config.ensure_not_wipe_code(pin)
else: else:
@ -131,7 +136,12 @@ async def verify_user_pin(
while retry: while retry:
pin = await request_pin_on_device( # type: ignore ["request_pin_on_device" is possibly unbound] pin = await request_pin_on_device( # type: ignore ["request_pin_on_device" is possibly unbound]
ctx, "Enter PIN", config.get_pin_rem(), allow_cancel, wrong_pin=True ctx,
"Enter PIN",
config.get_pin_rem(),
allow_cancel,
wrong_pin=True,
skip_button_request=skip_button_request,
) )
if config.unlock(pin, salt): if config.unlock(pin, salt):
_set_last_unlock_time() _set_last_unlock_time()

@ -59,7 +59,7 @@ def int_find_handler(
return None return None
async def wrapper(ctx: wire.Context, msg: wire.Msg) -> protobuf.MessageType: async def wrapper(ctx: wire.Context, msg: wire.Msg) -> protobuf.MessageType:
await unlock_device(ctx) await unlock_device(ctx, True)
return await orig_handler(ctx, msg) return await orig_handler(ctx, msg)
return wrapper return wrapper

Loading…
Cancel
Save