mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-15 10:02:00 +00:00
fix(ui-lvgl): no USB drive behind the screen PIN; drop the NVS PIN migration
The SD card (message history) could be lent to a computer from the lock card before the PIN was entered. While locked with a PIN, usbPoll() no longer reacts; a cable plugged in meanwhile is offered once unlocked. The plain-text NVS PIN never shipped, so there's nothing to migrate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -680,7 +680,6 @@ static int getU8(const char* ns, const char* key, int def) { return getInt(ns,
|
|||||||
static void putU8(const char* ns, const char* key, int v) { putInt(ns, key, v); }
|
static void putU8(const char* ns, const char* key, int v) { putInt(ns, key, v); }
|
||||||
static void getStr(const char* ns, const char* key, char* out, size_t n) { Kv* k = find(ns, key, false); snprintf(out, n, "%s", k ? k->val : ""); }
|
static void getStr(const char* ns, const char* key, char* out, size_t n) { Kv* k = find(ns, key, false); snprintf(out, n, "%s", k ? k->val : ""); }
|
||||||
static void putStr(const char* ns, const char* key, const char* v) { if (Kv* k = find(ns, key, true)) snprintf(k->val, sizeof(k->val), "%s", v); }
|
static void putStr(const char* ns, const char* key, const char* v) { if (Kv* k = find(ns, key, true)) snprintf(k->val, sizeof(k->val), "%s", v); }
|
||||||
static void remove(const char* ns, const char* key) { if (Kv* k = find(ns, key, false)) k->val[0] = '\0'; }
|
|
||||||
} // namespace nvs
|
} // namespace nvs
|
||||||
|
|
||||||
static bool s_swallow = false;
|
static bool s_swallow = false;
|
||||||
@@ -849,12 +848,6 @@ static bool vectorOn() { return nvs::getBool("mc_ui", "vector", false); }
|
|||||||
static void setVectorOn(bool on) { nvs::putBool("mc_ui", "vector", on); }
|
static void setVectorOn(bool on) { nvs::putBool("mc_ui", "vector", on); }
|
||||||
|
|
||||||
// Screen-lock PIN (Settings > Display & power > Screen PIN): digits, "" = none.
|
// Screen-lock PIN (Settings > Display & power > Screen PIN): digits, "" = none.
|
||||||
// The screen PIN as older builds kept it (plain text): read once and removed;
|
|
||||||
// it lives hashed in NodePrefs now (ui-core/ScreenLock.h).
|
|
||||||
static void takeOldPin(char* out, size_t n) {
|
|
||||||
nvs::getStr("mc_lock", "pin", out, n);
|
|
||||||
if (out[0]) nvs::remove("mc_lock", "pin");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accent colour (Settings > Display & power): an index into theme::ACCENTS.
|
// Accent colour (Settings > Display & power): an index into theme::ACCENTS.
|
||||||
static int loadAccent() { return nvs::getU8("mc_ui", "accent", 0); }
|
static int loadAccent() { return nvs::getU8("mc_ui", "accent", 0); }
|
||||||
|
|||||||
@@ -482,6 +482,9 @@ void UITask::usbPoll() {
|
|||||||
restartScreen("The computer has given the SD card back.");
|
restartScreen("The computer has given the SD card back.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Behind a screen PIN the card (message history) isn't offered: a cable
|
||||||
|
// plugged in while locked is noticed once the PIN is entered.
|
||||||
|
if (locked() && pinSet()) return;
|
||||||
bool host = lvport::usbHost();
|
bool host = lvport::usbHost();
|
||||||
if (host == s_host) return;
|
if (host == s_host) return;
|
||||||
s_host = host;
|
s_host = host;
|
||||||
@@ -499,7 +502,7 @@ void UITask::usbPoll() {
|
|||||||
void UITask::usbTap(bool drive) {
|
void UITask::usbTap(bool drive) {
|
||||||
using namespace usbview;
|
using namespace usbview;
|
||||||
if (s_overlay) { lv_obj_delete_async(s_overlay); s_overlay = nullptr; }
|
if (s_overlay) { lv_obj_delete_async(s_overlay); s_overlay = nullptr; }
|
||||||
if (!drive) return;
|
if (!drive || (locked() && pinSet())) return;
|
||||||
storeview::stopWalk();
|
storeview::stopWalk();
|
||||||
if (mapview::s_dl.active()) mapDownloadStop();
|
if (mapview::s_dl.active()) mapDownloadStop();
|
||||||
if (!lvport::usbDriveStart()) { showToast("No SD card to share", 3000); return; }
|
if (!lvport::usbDriveStart()) { showToast("No SD card to share", 3000); return; }
|
||||||
|
|||||||
@@ -898,14 +898,6 @@ void UITask::begin(DisplayDriver* display_drv, SensorManager* sensors, NodePrefs
|
|||||||
buildStatusBar();
|
buildStatusBar();
|
||||||
applyDisplayPrefs(); // a slider percentage overrides the level main.cpp set
|
applyDisplayPrefs(); // a slider percentage overrides the level main.cpp set
|
||||||
showHome();
|
showHome();
|
||||||
// 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
|
if (pinSet()) lockScreen(); // a reboot doesn't get round the PIN
|
||||||
showSplash(); // over both; fades out by itself
|
showSplash(); // over both; fades out by itself
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user