What changed, and why it matters
This is a routine build-fix refactor for the Trezor hardware wallet's bootloader UI. It removes the 'const' keyword from a few Rust functions and splits a battery icon rendering helper so the bootloader build succeeds. There is no security-relevant change visible in the diff.
No security action required; treat as normal build/maintenance fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit makes two non-functional changes in the ‘eckhart’ UI layout: (1) removes const from with_right_button, with_menu_button, and with_close_button in bld_header.rs, likely because the functions now call non-const code paths; (2) extracts duplicated icon-plus-percentage rendering in fuel_gauge.rs into a new render_icon_and_percentage helper and uses #[cfg] to compile different match arms depending on whether the ‘micropython’ feature is enabled. The diff shows no logic changes that affect input validation, cryptography, memory safety, or access control.
Changed components
core/embed/rust/src/ui/layout_eckhart/bootloader/bld_header.rscore/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rsInspect captured patch +21 / −13
diff --git a/core/embed/rust/src/ui/layout_eckhart/bootloader/bld_header.rs b/core/embed/rust/src/ui/layout_eckhart/bootloader/bld_header.rs
index a0eb1a49..61c58b57 100644
--- a/core/embed/rust/src/ui/layout_eckhart/bootloader/bld_header.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/bootloader/bld_header.rs
@@ -75,7 +75,7 @@ impl<'a> BldHeader<'a> {
}
#[inline(never)]
- pub const fn with_right_button(self, button: Button, msg: BldHeaderMsg) -> Self {
+ pub fn with_right_button(self, button: Button, msg: BldHeaderMsg) -> Self {
debug_assert!(matches!(button.content(), ButtonContent::Icon(_)));
let touch_area = Insets::uniform(BUTTON_EXPAND_BORDER);
Self {
@@ -86,7 +86,7 @@ impl<'a> BldHeader<'a> {
}
#[inline(never)]
- pub const fn with_menu_button(self) -> Self {
+ pub fn with_menu_button(self) -> Self {
self.with_right_button(
Button::with_icon(theme::ICON_MENU).styled(theme::bootloader::button_header()),
BldHeaderMsg::Menu,
@@ -94,7 +94,7 @@ impl<'a> BldHeader<'a> {
}
#[inline(never)]
- pub const fn with_close_button(self) -> Self {
+ pub fn with_close_button(self) -> Self {
self.with_right_button(
Button::with_icon(theme::ICON_CLOSE).styled(theme::bootloader::button_header()),
BldHeaderMsg::Cancelled,
diff --git a/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs b/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
index 35589eee..8eb63a5c 100644
--- a/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
@@ -155,6 +155,15 @@ impl FuelGauge {
}
}
}
+
+ fn render_icon_and_percentage<'s>(&self, area: Rect, target: &mut impl Renderer<'s>) {
+ self.render_icon(area, target);
+ let text_y_coord = self.font.vert_center(area.y0, area.y1, &self.soc_text);
+ shape::Text::new(Point::new(area.x1, text_y_coord), &self.soc_text, self.font)
+ .with_fg(self.battery_indication.2)
+ .with_align(Alignment::End)
+ .render(target);
+ }
}
impl Component for FuelGauge {
@@ -208,11 +217,11 @@ impl Component for FuelGauge {
}
fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
- let (icon, color_icon, color_text) = self.battery_indication;
let text_width = self.font.text_width(&self.soc_text);
let text_height = self.font.text_height();
- let icon_width = icon.toif.width();
- let icon_height = icon.toif.height();
+ let icon = self.battery_indication.0.toif;
+ let icon_width = icon.width();
+ let icon_height = icon.height();
let (point, alignment) = (self.area.left_center(), Alignment2D::CENTER_LEFT);
let area = Rect::snap(
@@ -233,14 +242,13 @@ impl Component for FuelGauge {
self.render_icon(area, target);
}
}
+ #[cfg(not(feature = "micropython"))]
+ FuelGaugeMode::AlwaysFull => {
+ self.render_icon_and_percentage(area, target);
+ }
+ #[cfg(feature = "micropython")]
FuelGaugeMode::AlwaysFull | FuelGaugeMode::OnChargingChange(..) => {
- // both icon and percentage
- self.render_icon(area, target);
- let text_y_coord = self.font.vert_center(area.y0, area.y1, &self.soc_text);
- shape::Text::new(Point::new(area.x1, text_y_coord), &self.soc_text, self.font)
- .with_fg(color_text)
- .with_align(Alignment::End)
- .render(target);
+ self.render_icon_and_percentage(area, target);
}
}
}
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.