mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
core/ui: Ignore any new alert requests if an alert is already in progress in order to avoid multiple alerts overlapping.
This commit is contained in:
parent
584dae7832
commit
3a4e9bd25c
@ -1027,7 +1027,7 @@ def dispatch_cmd(req: Cmd, dialog_mgr: DialogManager) -> Optional[Cmd]:
|
|||||||
elif req.cmd == _CMD_WINK:
|
elif req.cmd == _CMD_WINK:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
log.debug(__name__, "_CMD_WINK")
|
log.debug(__name__, "_CMD_WINK")
|
||||||
loop.schedule(ui.alert())
|
ui.alert()
|
||||||
return req
|
return req
|
||||||
elif req.cmd == _CMD_CBOR and _ALLOW_FIDO2:
|
elif req.cmd == _CMD_CBOR and _ALLOW_FIDO2:
|
||||||
if not req.data:
|
if not req.data:
|
||||||
|
@ -34,6 +34,9 @@ VIEWY = const(9)
|
|||||||
# channel used to cancel layouts, see `Cancelled` exception
|
# channel used to cancel layouts, see `Cancelled` exception
|
||||||
layout_chan = loop.chan()
|
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
|
# in debug mode, display an indicator in top right corner
|
||||||
if __debug__:
|
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)
|
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)
|
short_sleep = loop.sleep(20000)
|
||||||
long_sleep = loop.sleep(80000)
|
long_sleep = loop.sleep(80000)
|
||||||
for i in range(count * 2):
|
for i in range(count * 2):
|
||||||
@ -89,6 +92,17 @@ async def alert(count: int = 3) -> None:
|
|||||||
display.backlight(style.BACKLIGHT_DIM)
|
display.backlight(style.BACKLIGHT_DIM)
|
||||||
await long_sleep
|
await long_sleep
|
||||||
display.backlight(style.BACKLIGHT_NORMAL)
|
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:
|
async def click() -> Pos:
|
||||||
|
Loading…
Reference in New Issue
Block a user