diff --git a/core/src/apps/webauthn/fido2.py b/core/src/apps/webauthn/fido2.py index 1136945585..02ad16d475 100644 --- a/core/src/apps/webauthn/fido2.py +++ b/core/src/apps/webauthn/fido2.py @@ -1027,7 +1027,7 @@ def dispatch_cmd(req: Cmd, dialog_mgr: DialogManager) -> Optional[Cmd]: elif req.cmd == _CMD_WINK: if __debug__: log.debug(__name__, "_CMD_WINK") - loop.schedule(ui.alert()) + ui.alert() return req elif req.cmd == _CMD_CBOR and _ALLOW_FIDO2: if not req.data: diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py index e6b1ae990e..1b1ee3a389 100644 --- a/core/src/trezor/ui/__init__.py +++ b/core/src/trezor/ui/__init__.py @@ -34,6 +34,9 @@ VIEWY = const(9) # channel used to cancel layouts, see `Cancelled` exception layout_chan = loop.chan() +# allow only one alert at a time to avoid alerts overlapping +_alert_in_progress = False + # in debug mode, display an indicator in top right corner if __debug__: @@ -78,7 +81,7 @@ def pulse(period: int, offset: int = 0) -> float: return 0.5 + 0.5 * math.sin(2 * math.pi * (utime.ticks_us() + offset) / period) -async def alert(count: int = 3) -> None: +async def _alert(count: int) -> None: short_sleep = loop.sleep(20000) long_sleep = loop.sleep(80000) for i in range(count * 2): @@ -89,6 +92,17 @@ async def alert(count: int = 3) -> None: display.backlight(style.BACKLIGHT_DIM) await long_sleep display.backlight(style.BACKLIGHT_NORMAL) + global _alert_in_progress + _alert_in_progress = False + + +def alert(count: int = 3) -> None: + global _alert_in_progress + if _alert_in_progress: + return + + _alert_in_progress = True + loop.schedule(_alert(count)) async def click() -> Pos: