feat: Lock devices with password set on boot

This commit is contained in:
3urobeat
2026-09-06 17:52:41 +02:00
parent b710910225
commit 6404622ebf
2 changed files with 15 additions and 3 deletions
@@ -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.
+14 -2
View File
@@ -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();