Skip to content

Commit 4ee8985

Browse files
committed
fixup! fix(core): prevent homescreen flickering on Cancel message
1 parent d49cbc1 commit 4ee8985

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

core/src/apps/base.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import TYPE_CHECKING
22

3-
import storage.cache as storage_cache
43
import storage.device as storage_device
54
from storage.cache_common import APP_COMMON_BUSY_DEADLINE_MS, APP_COMMON_SEED
65
from trezor import TR, config, utils, wire, workflow
@@ -239,15 +238,8 @@ async def handle_GetFeatures(msg: GetFeatures) -> Features:
239238

240239

241240
async def handle_Cancel(msg: Cancel) -> Success:
242-
close_others = True
243-
if storage_cache.homescreen_shown is storage_cache.HOMESCREEN_ON:
244-
# Homescreen is shown and only this task is running
245-
if len(workflow.tasks) == 1 and next(iter(workflow.tasks)).is_running():
246-
# Prevent homescreen flickering on Cancel
247-
close_others = False
248-
249-
if close_others:
250-
workflow.close_others()
241+
# Prevent homescreen flickering on Cancel
242+
workflow.close_others(close_default=False)
251243

252244
raise wire.ActionCancelled
253245

core/src/trezor/workflow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ def kill_default() -> None:
136136
default_task.close()
137137

138138

139-
def close_others() -> None:
139+
def close_others(close_default: bool = True) -> None:
140140
"""Request workflow (and UI) exclusivity: shut down all running tasks, except
141141
the one that is currently executing.
142142
143143
If this is called from outside a registered workflow, it is equivalent to "close
144144
all tasks". In that case, the default task will be restarted afterwards.
145145
"""
146-
if default_task is not None and not default_task.is_running():
146+
if close_default and default_task is not None and not default_task.is_running():
147147
default_task.close()
148148
# if no other tasks are running, start_default will run immediately
149149

@@ -153,7 +153,8 @@ def close_others() -> None:
153153
if not task.is_running():
154154
task.close()
155155

156-
storage_cache.homescreen_shown = None
156+
if close_default:
157+
storage_cache.homescreen_shown = None
157158

158159
# if tasks were running, closing the last of them will run start_default
159160

0 commit comments

Comments
 (0)