refactor(core): inline `Layout.notify_debuglink()`
What changed, and why it matters
This is a small internal code cleanup in the Trezor firmware. It moves a debug-only helper function call directly to where it is used and removes an unnecessary wrapper. There is no user-facing change and no security fix.
No action required. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit inlines Layout.notify_debuglink(), a static method that only existed to import and call apps.debug.notify_layout_change. The import is moved to module level under if __debug__: and the three call sites now call notify_layout_change(...) directly. The dispatch_DebugLinkRecordScreen function also moves its from trezor.ui import display import to be local. All changes are guarded by if __debug__: and affect only debug builds.
Changed components
core/src/trezor/ui/__init__.pycore/src/apps/debug/__init__.pyInspect captured patch +7 / −10
diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py
index de39441c..fcae69e1 100644
--- a/core/src/apps/debug/__init__.py
+++ b/core/src/apps/debug/__init__.py
@@ -15,7 +15,6 @@ if __debug__:
from trezor import io, log, loop, ui, utils, wire, workflow
from trezor.enums import DebugTouchEventType, DebugWaitType, MessageType
from trezor.messages import Success
- from trezor.ui import display
if TYPE_CHECKING:
from typing import Any, Awaitable, Callable, NoReturn
@@ -344,6 +343,8 @@ if __debug__:
return _state(msg.return_empty_state)
async def dispatch_DebugLinkRecordScreen(msg: DebugLinkRecordScreen) -> Success:
+ from trezor.ui import display
+
if msg.target_directory:
# Ensure we consistently start at a layout, instead of randomly sometimes
# hitting the pause between layouts and rendering the "upcoming" one.
diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py
index 72d02089..3aea331d 100644
--- a/core/src/trezor/ui/__init__.py
+++ b/core/src/trezor/ui/__init__.py
@@ -35,6 +35,8 @@ else:
if __debug__:
from trezorui_api import disable_animation
+ from apps.debug import notify_layout_change
+
disable_animation(utils.DISABLE_ANIMATION)
@@ -144,12 +146,6 @@ class Layout(Generic[T]):
def __str__(self) -> str:
return f"{repr(self)}({self._trace(self.layout)[:150]})"
- @staticmethod
- def notify_debuglink(layout: "Layout | None") -> None:
- from apps.debug import notify_layout_change
-
- notify_layout_change(layout)
-
def __init__(self, layout: LayoutObj[T]) -> None:
"""Set up a layout."""
self.layout = layout
@@ -269,7 +265,7 @@ class Layout(Generic[T]):
log.error(__name__, msg)
else:
raise wire.FirmwareError(msg)
- self.notify_debuglink(None)
+ notify_layout_change(None)
async def get_result(self) -> T:
"""Wait for, and return, the result of this UI layout."""
@@ -351,7 +347,7 @@ class Layout(Generic[T]):
if self.button_request_ack_pending:
state = LayoutState.TRANSITIONING
elif __debug__:
- self.notify_debuglink(self)
+ notify_layout_change(self)
if state is not None:
self.state = state
@@ -497,7 +493,7 @@ class Layout(Generic[T]):
self.button_request_ack_pending = False
self.state = LayoutState.ATTACHED
if __debug__:
- self.notify_debuglink(self)
+ notify_layout_change(self)
if utils.USE_BLE:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.