diff --git a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs index 8461eaa078..938a96d3a6 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs @@ -64,7 +64,8 @@ impl FlowController for SetBrightness { static BRIGHTNESS: AtomicU8 = AtomicU8::new(0); -pub fn new_set_brightness(brightness: u8) -> Result { +pub fn new_set_brightness(brightness: Option) -> Result { + let brightness = brightness.unwrap_or(theme::backlight::get_backlight_normal()); let content_slider = Frame::left_aligned( TR::brightness__title.into(), NumberInputSliderDialog::new( @@ -122,6 +123,7 @@ pub fn new_set_brightness(brightness: u8) -> Result { ) .with_footer(TR::instructions__swipe_up.into(), None) .with_swipe(Direction::Up, SwipeSettings::default()) + .with_result_icon(theme::ICON_BULLET_CHECKMARK, theme::GREEN_LIGHT) .map(move |_msg| Some(FlowMsg::Confirmed)); let res = SwipeFlow::new(&SetBrightness::Slider)? diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 65358ce6c0..b2e39603a6 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -676,7 +676,7 @@ extern "C" fn new_confirm_summary(n_args: usize, args: *const Obj, kwargs: *mut extern "C" fn new_set_brightness(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let current: u8 = kwargs.get(Qstr::MP_QSTR_current)?.try_into()?; + let current: Option = kwargs.get(Qstr::MP_QSTR_current)?.try_into_option()?; let flow = flow::set_brightness::new_set_brightness(current)?; Ok(LayoutObj::new_root(flow)?.into()) }; diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index c879a122d2..0f512ac44a 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -22,7 +22,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.tools import parse_path -from ..input_flows import InputFlowConfirmAllWarnings +from ..input_flows import InputFlowConfirmAllWarnings, InputFlowSetBrightness HERE = Path(__file__).parent.resolve() @@ -421,3 +421,16 @@ def test_label_too_long(client: Client): with pytest.raises(exceptions.TrezorFailure), client: client.set_expected_responses([messages.Failure]) device.apply_settings(client, label="A" * 33) + + +@pytest.mark.models(skip=["legacy", "safe3"]) +@pytest.mark.setup_client(pin=None) +def test_set_brightness(client: Client): + with client: + IF = InputFlowSetBrightness(client) + client.set_input_flow(IF.get()) + # Set brightness to a default value + device.set_brightness( + client, + None, + ) diff --git a/tests/input_flows.py b/tests/input_flows.py index 79dbc56673..900cf0cd7c 100644 --- a/tests/input_flows.py +++ b/tests/input_flows.py @@ -291,6 +291,23 @@ def input_flow_t3t1(self) -> BRGeneratorType: self.debug.press_yes() +class InputFlowSetBrightness(InputFlowBase): + def __init__(self, client: Client): + super().__init__(client) + + def input_flow_tt(self) -> BRGeneratorType: + self.debug.press_yes() + yield + self.debug.press_yes() + yield + + def input_flow_t3t1(self) -> BRGeneratorType: + self.debug.swipe_up() + yield + self.debug.press_yes() + yield + + class InputFlowShowAddressQRCode(InputFlowBase): def __init__(self, client: Client): super().__init__(client)