diff --git a/core/src/apps/homescreen/lockscreen.py b/core/src/apps/homescreen/lockscreen.py index 94197eb1b..b2487e385 100644 --- a/core/src/apps/homescreen/lockscreen.py +++ b/core/src/apps/homescreen/lockscreen.py @@ -49,6 +49,13 @@ class Lockscreen(HomescreenBase): # and paint it. ui.display.clear() self.on_render() + + if __debug__ and self.should_notify_layout_change: + from apps.debug import notify_layout_change + + self.should_notify_layout_change = False + notify_layout_change(self) + ui.refresh() ui.backlight_fade(ui.BACKLIGHT_LOW) # long sleep diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py index daee3759e..e42c85cb1 100644 --- a/core/src/trezor/ui/__init__.py +++ b/core/src/trezor/ui/__init__.py @@ -310,6 +310,12 @@ class Layout(Component): Run the layout and wait until it completes. Returns the result value. Usually not overridden. """ + if __debug__: + # we want to call notify_layout_change() when the rendering is done; + # but only the first time the layout is awaited. Here we indicate that we + # are being awaited, and in handle_rendering() we send the appropriate event + self.should_notify_layout_change = True + value = None try: # If any other layout is running (waiting on the layout channel), @@ -322,8 +328,6 @@ class Layout(Component): # layout channel. This allows other layouts to cancel us, and the # layout tasks to trigger restart by exiting (new tasks are created # and we continue, because we are in a loop). - if __debug__: - notify_layout_change(self) while True: await loop.race(layout_chan.take(), *self.create_tasks()) except Result as result: @@ -365,6 +369,14 @@ class Layout(Component): display.clear() self.dispatch(REPAINT, 0, 0) self.dispatch(RENDER, 0, 0) + + if __debug__ and self.should_notify_layout_change: + # notify about change and do not notify again until next await. + # (handle_rendering might be called multiple times in a single await, + # because of the endless loop in __iter__) + self.should_notify_layout_change = False + notify_layout_change(self) + # Display is usually refreshed after every loop step, but here we are # rendering everything synchronously, so refresh it manually and turn # the brightness on again. diff --git a/tests/click_tests/test_reset_slip39_advanced.py b/tests/click_tests/test_reset_slip39_advanced.py index a7d8de02b..e0a0cd89d 100644 --- a/tests/click_tests/test_reset_slip39_advanced.py +++ b/tests/click_tests/test_reset_slip39_advanced.py @@ -48,7 +48,7 @@ def test_reset_slip39_advanced_2of2groups_2of2shares(device_handler): reset.confirm_wait(debug, "Create new wallet") # confirm back up - reset.confirm_wait(debug, "Success") + reset.confirm_read(debug, "Success") # confirm checklist reset.confirm_read(debug, "Checklist") @@ -130,7 +130,7 @@ def test_reset_slip39_advanced_16of16groups_16of16shares(device_handler): reset.confirm_wait(debug, "Create new wallet") # confirm back up - reset.confirm_wait(debug, "Success") + reset.confirm_read(debug, "Success") # confirm checklist reset.confirm_read(debug, "Checklist") diff --git a/tests/click_tests/test_reset_slip39_basic.py b/tests/click_tests/test_reset_slip39_basic.py index 92993078f..6ab870f39 100644 --- a/tests/click_tests/test_reset_slip39_basic.py +++ b/tests/click_tests/test_reset_slip39_basic.py @@ -48,7 +48,7 @@ def test_reset_slip39_basic_1of1(device_handler): reset.confirm_wait(debug, "Create new wallet") # confirm back up - reset.confirm_wait(debug, "Success") + reset.confirm_read(debug, "Success") # confirm checklist reset.confirm_read(debug, "Checklist") @@ -120,7 +120,7 @@ def test_reset_slip39_basic_16of16(device_handler): reset.confirm_wait(debug, "Create new wallet") # confirm back up - reset.confirm_wait(debug, "Success") + reset.confirm_read(debug, "Success") # confirm checklist reset.confirm_read(debug, "Checklist") diff --git a/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py b/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py index 20d5da52b..1300882a8 100644 --- a/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py +++ b/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py @@ -73,9 +73,11 @@ def do_recover_core(client, mnemonic, **kwargs): yield for word in mnemonic: + client.debug.wait_layout() client.debug.input(word) yield + client.debug.wait_layout() client.debug.click(buttons.OK) with client: