コード例 #1
0
ファイル: workflow.py プロジェクト: mcudev/trezor-firmware
    def set(self, timeout_ms: int, callback: IdleCallback) -> None:
        """Add or update an idle callback.

        Every time `timeout_ms` milliseconds elapse after the last registered activity,
        `callback` will be invoked.
        I.e., in every period of inactivity, each `callback` will only run once. To run
        again, an activity must be registered and then no activity for the specified
        period.

        If `callback` was previously registered, it is updated with a new timeout value.

        `idle_timer.set()` also counts as an activity, so all running idle timers are
        reset.
        """
        # The reason for counting set() as an activity is to clear up an ambiguity that
        # would arise otherwise. This does not matter now, as callbacks are only
        # scheduled during periods of activity.
        # If we ever need to add a callback without touching, we will need to know
        # when this callback should execute (10 mins from now? from last activity? if
        # the latter, what if 10 minutes have already elapsed?)
        if callback in self.tasks:
            loop.close(self.tasks[callback])

        self.timeouts[callback] = timeout_ms
        self.tasks[callback] = self._timeout_task(callback)
        self.touch()
コード例 #2
0
ファイル: workflow.py プロジェクト: vodelerk/trezor-core
def closedefault():
    global default

    if default:
        loop.close(default)
        default = None
        log.debug(__name__, 'closedefault')
コード例 #3
0
def close_default() -> None:
    """Explicitly close the default workflow task."""
    global default_task

    if default_task:
        loop.close(default_task)
        default_task = None
コード例 #4
0
def close_default() -> None:
    """Explicitly close the default workflow task."""
    if default_task:
        if __debug__:
            log.debug(__name__, "close default")
        # We let the `_finalize_default` reset the global.
        loop.close(default_task)
コード例 #5
0
 def compare(self, action: int, checksum: bytes) -> bool:
     if self.action != action or self.checksum != checksum:
         return False
     if utime.ticks_ms() >= self.deadline:
         if self.workflow is not None:
             loop.close(self.workflow)
         return False
     return True
コード例 #6
0
ファイル: __init__.py プロジェクト: qjawe/trezor-core
 async def inner(*args, **kwargs):
     await backlight_slide(BACKLIGHT_DIM, delay, step)
     slide = backlight_slide(BACKLIGHT_NORMAL, delay, step)
     try:
         loop.schedule(slide)
         return await f(*args, **kwargs)
     finally:
         loop.close(slide)
コード例 #7
0
 def compare(self, action: int, checksum: bytes) -> bool:
     if self.action != action or self.checksum != checksum:
         return False
     if utime.ticks_ms() >= self.deadline:
         if self.workflow is not None:
             # We crossed the deadline, kill the running confirmation
             # workflow. `self.workflow` is reset in the finally
             # handler in `confirm_workflow`.
             loop.close(self.workflow)
         return False
     return True
コード例 #8
0
 async def inner(*args, **kwargs):
     await backlight_slide(BACKLIGHT_DIM)
     slide = backlight_slide(BACKLIGHT_NORMAL)
     try:
         layout = f(*args, **kwargs)
         workflow.onlayoutstart(layout)
         loop.schedule(slide)
         return await layout
     finally:
         loop.close(slide)
         workflow.onlayoutclose(layout)
コード例 #9
0
    def setup(self, action: int, checksum: bytes, app_id: bytes) -> None:
        if self.workflow is not None:
            loop.close(self.workflow)
        if workflow.workflows:
            return False

        self.action = action
        self.checksum = checksum
        self.app_id = app_id

        self.confirmed = None
        self.workflow = self.confirm_workflow()
        loop.schedule(self.workflow)
        return True
コード例 #10
0
def kill_default() -> None:
    """Forcefully shut down default task.

    The purpose of the call is to prevent the default task from interfering with
    a synchronous layout-less workflow (e.g., the progress bar in `mnemonic.get_seed`).

    This function should only be called from a workflow registered with `on_start`.
    Otherwise the default will be restarted immediately.
    """
    if default_task:
        if __debug__:
            log.debug(__name__, "close default")
        # We let the `_finalize_default` reset the global.
        loop.close(default_task)
コード例 #11
0
ファイル: workflow.py プロジェクト: mcudev/trezor-firmware
 def remove(self, callback: IdleCallback) -> None:
     """Remove an idle callback."""
     self.timeouts.pop(callback, None)
     task = self.tasks.pop(callback, None)
     if task is not None:
         loop.close(task)
コード例 #12
0
 def kill(self) -> None:
     if self.task is not None:
         workflow.onclose(self.task)
         loop.close(self.task)
         self.task = None
コード例 #13
0
ファイル: workflow.py プロジェクト: jakezeal/trezor-core
def closedefault():
    global default

    if default:
        loop.close(default)
        default = None
コード例 #14
0
ファイル: codec_v2.py プロジェクト: zhaojun-sh/trezor-core
 def close(self, sid):
     if sid in self.handling_tasks:
         task = self.handling_tasks.pop(sid)
         loop.close(task)
コード例 #15
0
 def kill(self) -> None:
     if self.task is not None:
         loop.close(self.task)
         self.task = None
コード例 #16
0
def close_default() -> None:
    """Explicitly close the default workflow task."""
    if default_task:
        # We let the `_finalize_default` reset the global.
        loop.close(default_task)