From 6404622ebf424d24d15ec429b9d0fab30474ea47 Mon Sep 17 00:00:00 2001 From: 3urobeat Date: Sun, 6 Sep 2026 17:52:41 +0200 Subject: [PATCH] feat: Lock devices with password set on boot --- docs/solo_features/screen_lock/screen_lock.md | 2 +- examples/companion_radio/ui-new/UITask.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/solo_features/screen_lock/screen_lock.md b/docs/solo_features/screen_lock/screen_lock.md index 339eaa79..0297a6f6 100644 --- a/docs/solo_features/screen_lock/screen_lock.md +++ b/docs/solo_features/screen_lock/screen_lock.md @@ -68,7 +68,7 @@ Fully autonomous, independent of Auto-lock and of any key combo: ### Lock-screen password -Enable **LockPass** in **Settings › Display** to require a password when unlocking the device. +Enable **LockPass** in **Settings › Display** to require a password when unlocking or powering up the device. Upon enabling the setting the keyboard will show, requiring you to submit a new password. Attempting to unlock the device will then require the same password to be typed and submitted to reach the home screen. diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 56a0b465..7171e2fb 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -1592,6 +1592,13 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no } #endif + // Lock device on boot if password is enabled to prevent bypassing it by resetting device + if (passwordLockEnabled()) { + _locked = true; + // Add BOOT_SCREEN_MILLIS to make sure splash screen still shows + _lock_wake_until = millis() + BOOT_SCREEN_MILLIS + 5000; + } + #if defined(PIN_USER_BTN) user_btn.begin(); #endif @@ -2976,12 +2983,17 @@ void UITask::loop() { _next_refresh = millis() + delay_millis; } else if (_locked && millis() >= _next_refresh && home) { _display->startFrame(); - home->render(*_display); + if (curr && curr != home) { + // Boot splash is still up on a boot-locked device + _next_refresh = millis() + curr->render(*_display); + } else { + home->render(*_display); + _next_refresh = millis() + Features::LOCKSCREEN_REFRESH_MS; + } // Alert overlay on top — without this a ringing alarm on a locked device // played its melody against a screen that never said what was ringing. if (millis() < _alert_expiry) renderAlertOverlay(); _display->endFrame(); - _next_refresh = millis() + Features::LOCKSCREEN_REFRESH_MS; } else if (!_locked && millis() >= _next_refresh && curr) { _display->startFrame(); _kb.beginFrame();