From d48cfa730bf21593b684efeaf3fd8940695e1dea Mon Sep 17 00:00:00 2001 From: Nayan Date: Fri, 14 Aug 2026 17:21:34 -0400 Subject: [PATCH] ui: dismiss screensaver on wake instead of on awake transition (#1907) * fix wake-up behavior * ui: dismiss screensaver on wake instead of on awake transition --------- Co-authored-by: Jason Wen --- openpilot/selfdrive/ui/sunnypilot/ui_state.py | 17 ++++++++++++----- openpilot/selfdrive/ui/ui_state.py | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openpilot/selfdrive/ui/sunnypilot/ui_state.py b/openpilot/selfdrive/ui/sunnypilot/ui_state.py index 510f19383a..602830a4db 100644 --- a/openpilot/selfdrive/ui/sunnypilot/ui_state.py +++ b/openpilot/selfdrive/ui/sunnypilot/ui_state.py @@ -241,19 +241,26 @@ class DeviceSP: def _set_awake(self, on: bool, _ui_state=None): self._blocked_by_screensaver = False - if _ui_state.boot_offroad_mode == 1 and not on: - _ui_state.params.put_bool("OffroadMode", True) - if not on and _ui_state.screensaver_enabled: if _ui_state.screensaver.was_dismissed: - if gui_app.get_active_widget() == _ui_state.screensaver: - gui_app.pop_widget() + self.dismiss_screensaver(_ui_state) elif _ui_state.screensaver.is_active: self._blocked_by_screensaver = True else: _ui_state.screensaver.initialize() gui_app.push_widget(_ui_state.screensaver) self._blocked_by_screensaver = True + else: + self.dismiss_screensaver(_ui_state) + + # blocked runs every frame, so write only when actually sleeping + if _ui_state.boot_offroad_mode == 1 and not on and not self._blocked_by_screensaver: + _ui_state.params.put_bool("OffroadMode", True) + + def dismiss_screensaver(self, _ui_state) -> None: + if gui_app.get_active_widget() == _ui_state.screensaver: + gui_app.pop_widget() + self._blocked_by_screensaver = False @staticmethod def set_onroad_brightness(_ui_state, awake: bool, cur_brightness: float) -> float: diff --git a/openpilot/selfdrive/ui/ui_state.py b/openpilot/selfdrive/ui/ui_state.py index ec5e1a27a4..e0aca74ff2 100644 --- a/openpilot/selfdrive/ui/ui_state.py +++ b/openpilot/selfdrive/ui/ui_state.py @@ -347,6 +347,10 @@ class Device(DeviceSP): self._set_awake(ui_state.ignition or not interaction_timeout or PC) def _set_awake(self, on: bool, _ui_state=None): + # screensaver holds _awake True, so waking is not a state change + if on and self._blocked_by_screensaver: + self.dismiss_screensaver(_ui_state or ui_state) + if on != self._awake: super()._set_awake(on, _ui_state or ui_state) if self._blocked_by_screensaver: