1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00

feat(core): log ButtonRequests with names for easier debugging

This commit is contained in:
matejcik 2024-11-08 14:18:42 +01:00 committed by matejcik
parent b2328a4e28
commit 34d97ee942
2 changed files with 13 additions and 0 deletions

View File

@ -257,6 +257,8 @@ class Layout(Generic[T]):
set_current_layout(None)
if __debug__:
if self.button_request_ack_pending:
raise wire.FirmwareError("button request ack pending")
self.notify_debuglink(None)
async def get_result(self) -> T:
@ -416,12 +418,16 @@ class Layout(Generic[T]):
self.button_request_box,
)
if __debug__:
log.info(__name__, "ButtonRequest sent: %s", br_name)
await self.context.call(
ButtonRequest(
code=br_code, pages=self.layout.page_count(), name=br_name
),
ButtonAck,
)
if __debug__:
log.info(__name__, "ButtonRequest acked: %s", br_name)
if (
self.button_request_ack_pending

View File

@ -6,6 +6,9 @@ from trezor.enums import ButtonRequestType
from trezor.messages import ButtonAck, ButtonRequest
from trezor.wire import ActionCancelled, context
if __debug__:
from trezor import log
if TYPE_CHECKING:
from typing import Any, Awaitable, Callable, TypeVar
@ -23,9 +26,13 @@ async def _button_request(
pages: int = 0,
) -> None:
workflow.close_others()
if __debug__:
log.info(__name__, "ButtonRequest sent: %s", br_name)
await context.maybe_call(
ButtonRequest(code=code, pages=pages or None, name=br_name), ButtonAck
)
if __debug__:
log.info(__name__, "ButtonRequest acked: %s", br_name)
async def interact(