Skip to content

feat(settings): add a Lock Screen toggle that keeps the idle screen-off - #248

Open
guohui85 wants to merge 1 commit into
CardputerZero:masterfrom
guohui85:feat/lock-screen-toggle
Open

guohui85 wants to merge 1 commit into
CardputerZero:masterfrom
guohui85:feat/lock-screen-toggle

Conversation

@guohui85

Copy link
Copy Markdown
Contributor

Summary

Adds Settings → Screen → Lock Screen (On / Off), as discussed in #245.

  • On (default): no change. The idle timeout locks the device; unlocking takes any key, then TAB, then ENTER.
  • Off: the idle timeout still blacks the panel and turns the backlight off, so the power saving stays. No lock sound plays, and the first key press wakes straight back to the launcher. The waking key is consumed, so it does not also act on the page.

Implements #245 (now closed). This is the PR requested in that issue.

Change

  • ui/settings/settings_page.cpp: a toggle entry Lock Screen under Screen. It follows the Bluetooth "Named Only" pattern: GetInt / SetInt / Save on a new config key lock_screen, default 1. If the save fails, the previous value is written back.
  • ui/ui_screensaver.cpp: enter_lockscreen() reads lock_screen on every lock, so a change applies at the next lock without a restart. When it is off, lock.mp3 is skipped, and ui_screensaver_filter_key() calls stop_screensaver(true, true) on the first fresh press before LockscreenStateModel sees the key.

Tests

  • test_settings_menu_order.py: the Screen entries are now Brightness, DarkTime, Lock Screen.
  • test_lockscreen_contract.py: pins the wiring (the read on lock, the skipped sound, the bypass placed before s_lock.handle_key).
  • low_battery_ui/test_low_battery_ui.cpp:
    • the config stub now answers per key (lock_screen → "1" by default). Before, it returned the timeout for every key, so lock_screen read as "0";
    • new test_lock_screen_off_wakes_on_any_key: no sound on lock, the backlight is off, any key is consumed and wakes the screen, and switching back on restores the TAB → ENTER lock.

Results:

  • sh projects/APPLaunch/tests/run_tests.sh: passes, except test_settings_software_page_contract.py. That test fails on current master as well (it expects CONFIG_APPLAUNCH_LINUX_X86_CROSS_CP0 in the SConstruct), so I skipped it locally.
  • bash projects/APPLaunch/tests/low_battery_ui/run_tests.sh: passes for both the device and SDL keyboard backends. On unmodified master the same harness passes as well.
  • The SDL2 build compiles both changed files. The only build error is settings_http_worker.cpp needing curl/curl.h, which my build image did not have; it is unrelated to this change.
  • On my device, on 0.6.105: with Lock Screen off, the screen goes dark after the timeout and any key brings the launcher back with no sound. With it on, the lock works as before. The setting survives a reboot.

Note

I prepared this with AI assistance (Claude) and tested it on my own device. Happy to change the wording, for example "Wake with any key", or to move the entry if you prefer.

- Settings > Screen > Lock Screen (config key "lock_screen", default on),
  using the same GetInt/SetInt/Save pattern as Bluetooth "Named Only".
- Off: the idle timeout still blacks the panel and turns the backlight
  off, but no lock sound plays and the first key press wakes straight
  back to the launcher. The waking key is consumed, so it does not act
  on the page. On keeps today's TAB then ENTER unlock.
- ui_screensaver.cpp reads the setting on every lock, so a change takes
  effect at the next lock without a restart.
- Tests: the Screen menu order test lists the new entry, the lock-screen
  contract pins the wiring, and the LVGL harness answers config reads per
  key and covers the off path (no sound, any key wakes, consumed) and
  switching back on.

Closes CardputerZero#245

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0135vUaG2FpgpGRJfB9LEPvZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant