avoid flicker when changing from lockscreen to waiting screen
What changed, and why it matters
This commit is a user-interface polish fix. It removes a brief screen flicker when the BitBox02 hardware wallet switches from the lockscreen message ('See the BitBoxApp') to the waiting logo screen. The change folds the lockscreen into the main waiting component and updates it at the right moment when the host computer connects. There is no security-relevant behavior change.
No security action needed. Treat as a normal UI/UX improvement during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the waiting/lockscreen UI component lifecycle. Previously, a lockscreen component was pushed onto the screen stack and later popped when a Noise handshake began, causing a visible flicker. The new code embeds the lockscreen as the initial sub-component of the waiting screen and provides a waiting_switch_to_logo() function that replaces the lockscreen child with the logo image. The Rust hww packet processor calls screen_process_waiting_switch_to_logo() either immediately (if the device is uninitialized) or when it receives the OP_UNLOCK packet (if initialized), so the logo appears only after the host has progressed far enough to avoid a flash. The change also removes the explicit lockscreen push in orientation_screen.c because the waiting screen now owns the lockscreen.
Changed components
BitBox02 firmware UI layerwaiting screen componentscreen processRust hww packet processororientation screen workflowInspect captured patch +67 / −13
diff --git a/src/rust/bitbox02-rust/src/hww.rs b/src/rust/bitbox02-rust/src/hww.rs
index c9f7511..99c4056 100644
--- a/src/rust/bitbox02-rust/src/hww.rs
+++ b/src/rust/bitbox02-rust/src/hww.rs
@@ -110,6 +110,13 @@ fn api_attestation(usb_in: &[u8]) -> Vec<u8> {
}
async fn _process_packet(hal: &mut impl crate::hal::Hal, usb_in: Vec<u8>) -> Vec<u8> {
+ // Update the waiting screen from "See the BitBoxApp" to the logo, now that the host is
+ // connected. When the device is initialized, we delay this until the unlock call, otherwise
+ // there would be a flicker where the logo would be shown before the host invokes unlock.
+ if !bitbox02::memory::is_initialized() || usb_in.as_slice() == [OP_UNLOCK] {
+ bitbox02::ui::screen_process_waiting_switch_to_logo();
+ }
+
match usb_in.split_first() {
Some((&OP_UNLOCK, b"")) => return api_unlock(hal).await,
Some((&OP_ATTESTATION, rest)) => return api_attestation(rest),
diff --git a/src/rust/bitbox02-rust/src/hww/noise.rs b/src/rust/bitbox02-rust/src/hww/noise.rs
index 9ee3156..df063d0 100644
--- a/src/rust/bitbox02-rust/src/hww/noise.rs
+++ b/src/rust/bitbox02-rust/src/hww/noise.rs
@@ -82,8 +82,6 @@ pub(crate) async fn process(
) -> Result<(), Error> {
match usb_in.split_first() {
Some((&OP_I_CAN_HAS_HANDSHAEK, b"")) => {
- // The previous screen was "See the BitBoxApp".
- // Since a handshake was requested, a client was connected, so we pop that screen.
// Pairing is the start of a session, so we clean the screen stack in case
// we started a new session in the middle of something.
bitbox02::ui::screen_stack_pop_all();
diff --git a/src/rust/bitbox02-sys/build.rs b/src/rust/bitbox02-sys/build.rs
index 3734b18..78c7597 100644
--- a/src/rust/bitbox02-sys/build.rs
+++ b/src/rust/bitbox02-sys/build.rs
@@ -128,6 +128,7 @@ const ALLOWLIST_FNS: &[&str] = &[
"reset_ble",
"screen_print_debug",
"screen_process",
+ "screen_process_waiting_switch_to_logo",
"screen_saver_disable",
"screen_saver_enable",
"sd_card_inserted",
diff --git a/src/rust/bitbox02/src/ui.rs b/src/rust/bitbox02/src/ui.rs
index e202ba6..507845c 100644
--- a/src/rust/bitbox02/src/ui.rs
+++ b/src/rust/bitbox02/src/ui.rs
@@ -25,3 +25,7 @@ mod types;
mod ui;
pub use ui::*;
+
+pub fn screen_process_waiting_switch_to_logo() {
+ unsafe { bitbox02_sys::screen_process_waiting_switch_to_logo() }
+}
diff --git a/src/ui/components/waiting.c b/src/ui/components/waiting.c
index 88b7513..409d478 100644
--- a/src/ui/components/waiting.c
+++ b/src/ui/components/waiting.c
@@ -13,6 +13,7 @@
// limitations under the License.
#include "waiting.h"
+#include "lockscreen.h"
#include "image.h"
#include "ui_images.h"
@@ -21,13 +22,12 @@
#include <screen.h>
#include <ui/ui_util.h>
+#include <stdbool.h>
#include <string.h>
-static void _render(component_t* component)
-{
- // TODO - add an interesting animation?
- ui_util_component_render_subcomponents(component);
-}
+typedef struct {
+ bool show_logo;
+} data_t;
/********************************** Component Functions **********************************/
@@ -36,7 +36,7 @@ static void _render(component_t* component)
*/
static component_functions_t _component_functions = {
.cleanup = ui_util_component_cleanup,
- .render = _render,
+ .render = ui_util_component_render_subcomponents,
.on_event = NULL,
};
@@ -47,6 +47,12 @@ static component_functions_t _component_functions = {
*/
component_t* waiting_create(void)
{
+ data_t* data = malloc(sizeof(data_t));
+ if (!data) {
+ Abort("Error: malloc waiting data");
+ }
+ memset(data, 0, sizeof(data_t));
+
component_t* waiting = malloc(sizeof(component_t));
if (!waiting) {
Abort("Error: malloc waiting");
@@ -57,6 +63,29 @@ component_t* waiting_create(void)
waiting->dimension.height = SCREEN_HEIGHT;
waiting->position.top = 0;
waiting->position.left = 0;
+ waiting->data = data;
+
+ ui_util_add_sub_component(waiting, lockscreen_create());
+
+ return waiting;
+}
+
+void waiting_switch_to_logo(component_t* component)
+{
+ data_t* data = (data_t*)component->data;
+ if (data->show_logo) {
+ return;
+ }
+ data->show_logo = true;
+
+ if (component->sub_components.amount != 1) {
+ // Sanity check to avoid memory bugs, should never happen.
+ Abort("waiting_switch_to_logo");
+ return;
+ }
+
+ ui_util_component_cleanup(component->sub_components.sub_components[0]);
+
image_logo_data_t logo = image_logo_data();
component_t* bb2_logo = image_create(
logo.buffer.data,
@@ -64,7 +93,7 @@ component_t* waiting_create(void)
logo.dimensions.width,
logo.dimensions.height,
CENTER,
- waiting);
- ui_util_add_sub_component(waiting, bb2_logo);
- return waiting;
+ component);
+
+ component->sub_components.sub_components[0] = bb2_logo;
}
diff --git a/src/ui/components/waiting.h b/src/ui/components/waiting.h
index 50916dc..6fecc9d 100644
--- a/src/ui/components/waiting.h
+++ b/src/ui/components/waiting.h
@@ -18,8 +18,14 @@
#include <ui/component.h>
/**
- * Creates a waiting screen.
+ * Creates a waiting screen. It starts out with a lockscreen (see lockscreen.c). Once
+ * `waiting_switch_to_logo()` is called, the waiting screen will switch to showing the logo image.
*/
component_t* waiting_create(void);
+/**
+ * Switch the waiting screen to show the BitBox logo instead.
+ */
+void waiting_switch_to_logo(component_t* component);
+
#endif
diff --git a/src/ui/screen_process.c b/src/ui/screen_process.c
index c927574..9e84a09 100644
--- a/src/ui/screen_process.c
+++ b/src/ui/screen_process.c
@@ -44,6 +44,11 @@ static component_t* _get_waiting_screen(void)
return waiting_screen;
}
+void screen_process_waiting_switch_to_logo(void)
+{
+ waiting_switch_to_logo(_get_waiting_screen());
+}
+
component_t* screen_process_get_top_component(void)
{
component_t* saver = screen_saver_get();
diff --git a/src/ui/screen_process.h b/src/ui/screen_process.h
index 0f26ed9..699754b 100644
--- a/src/ui/screen_process.h
+++ b/src/ui/screen_process.h
@@ -27,6 +27,11 @@ void ui_screen_render_component(component_t* component);
*/
component_t* screen_process_get_top_component(void);
+/**
+ * Wraps `waiting_switch_to_logo()` for the waiting screen.
+ */
+void screen_process_waiting_switch_to_logo(void);
+
/**
* Runs the UI once.
*
diff --git a/src/workflow/orientation_screen.c b/src/workflow/orientation_screen.c
index 011390e..5a0a2e0 100644
--- a/src/workflow/orientation_screen.c
+++ b/src/workflow/orientation_screen.c
@@ -73,7 +73,6 @@ static void _idle_timer_cb(const struct timer_task* const timer_task)
}
usb_start();
- ui_screen_stack_push(lockscreen_create());
}
#endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.