mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
[no changelog] Refactor arithmetic operations in fido2.py to use utime.ticks_add() and utime.ticks_diff()
This commit is contained in:
parent
d76829f817
commit
9f9354a820
@ -985,7 +985,7 @@ class DialogManager:
|
|||||||
|
|
||||||
def reset_timeout(self) -> None:
|
def reset_timeout(self) -> None:
|
||||||
if self.state is not None:
|
if self.state is not None:
|
||||||
self.deadline = utime.ticks_ms() + self.state.timeout_ms()
|
self.deadline = utime.ticks_add(utime.ticks_ms(), self.state.timeout_ms())
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
if self.workflow is not None:
|
if self.workflow is not None:
|
||||||
@ -1002,7 +1002,7 @@ class DialogManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def is_busy(self) -> bool:
|
def is_busy(self) -> bool:
|
||||||
if utime.ticks_ms() >= self.deadline:
|
if utime.ticks_diff(utime.ticks_ms(), self.deadline) >= 0:
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
if not self._workflow_is_running():
|
if not self._workflow_is_running():
|
||||||
@ -1015,7 +1015,10 @@ class DialogManager:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def set_state(self, state: State) -> bool:
|
def set_state(self, state: State) -> bool:
|
||||||
if self.state == state and utime.ticks_ms() < self.deadline:
|
if (
|
||||||
|
self.state == state
|
||||||
|
and utime.ticks_diff(utime.ticks_ms(), self.deadline) < 0
|
||||||
|
):
|
||||||
self.reset_timeout()
|
self.reset_timeout()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -1036,7 +1039,7 @@ class DialogManager:
|
|||||||
try:
|
try:
|
||||||
if not state:
|
if not state:
|
||||||
return
|
return
|
||||||
while utime.ticks_ms() < self.deadline:
|
while utime.ticks_diff(utime.ticks_ms(), self.deadline) < 0:
|
||||||
if state.keepalive_status() != _KEEPALIVE_STATUS_NONE:
|
if state.keepalive_status() != _KEEPALIVE_STATUS_NONE:
|
||||||
cmd = cmd_keepalive(state.cid, state.keepalive_status())
|
cmd = cmd_keepalive(state.cid, state.keepalive_status())
|
||||||
await send_cmd(cmd, self.iface)
|
await send_cmd(cmd, self.iface)
|
||||||
|
Loading…
Reference in New Issue
Block a user