mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-09 03:06:39 +00:00
Merge PR #37: lock screen PIN (3urobeat), adapted
The contributor's feature -- a PIN asked before the screen unlocks, on
boot, and when the magnet cover opens, stored as a salted SHA-256 -- on
top of this branch, with:
- ui-core/ScreenLock.h: set / check / isSet and the tries limit, shared by
L1 and L2. isSet looks at every byte (the PR tested only the first, so one
PIN in 256 silently disabled the lock). 5 misses pause entry for 30 s.
- NodePrefs: the fields at the tail after quiet hours, sentinel 0xC0DE0031,
sizeof 2880; an older file's bytes there are cleared. A sentinel bump no
longer resets display_brightness_pct from a file that already has it.
- DataStore: no AGPL header (the project is MIT), no whitespace churn.
- Keyboard: the number pad is a widget flag (pin_mode) with a prompt in the
preview ("New PIN", "Again", "PIN"), not keyboard_type = 2 written into the
prefs and restored after.
- L1 Settings: "Lock PIN" right after the schema's "Lock screen" row, typed
twice, at least 4 characters, saved at once (a power-off right after
setting it kept no PIN). Home is told about a boot-time lock once it
exists (also fixes booting with the cover closed).
- L2: the screen PIN moves from plain text in NVS to the same hash in
NodePrefs; the old one is migrated on first boot and removed. The pad
unlocks as soon as the hash matches from 4 digits on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -898,8 +898,15 @@ void UITask::begin(DisplayDriver* display_drv, SensorManager* sensors, NodePrefs
|
||||
buildStatusBar();
|
||||
applyDisplayPrefs(); // a slider percentage overrides the level main.cpp set
|
||||
showHome();
|
||||
lvport::loadPin(_pin, sizeof(_pin));
|
||||
if (_pin[0]) lockScreen(); // a reboot doesn't get round the PIN
|
||||
// Before the PIN moved into NodePrefs it was kept in NVS in plain text.
|
||||
char old_pin[9];
|
||||
lvport::takeOldPin(old_pin, sizeof(old_pin));
|
||||
if (old_pin[0] && _prefs && !pinSet()) {
|
||||
screenlock::set(*_prefs, old_pin, the_mesh.getRNG());
|
||||
the_mesh.savePrefs();
|
||||
}
|
||||
memset(old_pin, 0, sizeof(old_pin));
|
||||
if (pinSet()) lockScreen(); // a reboot doesn't get round the PIN
|
||||
showSplash(); // over both; fades out by itself
|
||||
}
|
||||
|
||||
@@ -1175,7 +1182,7 @@ void UITask::sleep() {
|
||||
if (_display) _display->turnOff();
|
||||
prefsSaveSoon(0); // nothing to stall now
|
||||
lvport::powerSave(true, _tap_wake);
|
||||
if ((_prefs && _prefs->auto_lock) || _pin[0]) lockScreen(); // Lock screen, or a screen PIN
|
||||
if ((_prefs && _prefs->auto_lock) || pinSet()) lockScreen(); // Lock screen, or a screen PIN
|
||||
}
|
||||
|
||||
void UITask::wake() {
|
||||
@@ -3212,7 +3219,7 @@ void UITask::buildSchemaSettings() {
|
||||
lv_obj_add_event_cb(tw, onTapWake, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
g = group(body, "LOCK");
|
||||
schemaRow(g, SETTING(auto_lock));
|
||||
listRow(g, "Screen PIN", _pin[0] ? "On - asked when the screen wakes" : "Off", onPinSetup, NULL);
|
||||
listRow(g, "Screen PIN", pinSet() ? "On - asked when the screen wakes" : "Off", onPinSetup, NULL);
|
||||
accentRow(group(body, "LOOK")); // DeviceScreen.h
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user