From e28b5c5c51d2ef6bb3a9f9b6b08fa3e88522ae04 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:13:33 +0200 Subject: [PATCH] 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 --- examples/companion_radio/ui-lvgl/LvglPort.h | 7 ------- examples/companion_radio/ui-lvgl/StorageScreen.h | 5 ++++- examples/companion_radio/ui-lvgl/UITask.cpp | 8 -------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/examples/companion_radio/ui-lvgl/LvglPort.h b/examples/companion_radio/ui-lvgl/LvglPort.h index 2ea27e07..afe0e741 100644 --- a/examples/companion_radio/ui-lvgl/LvglPort.h +++ b/examples/companion_radio/ui-lvgl/LvglPort.h @@ -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 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 remove(const char* ns, const char* key) { if (Kv* k = find(ns, key, false)) k->val[0] = '\0'; } } // namespace nvs 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); } // 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. static int loadAccent() { return nvs::getU8("mc_ui", "accent", 0); } diff --git a/examples/companion_radio/ui-lvgl/StorageScreen.h b/examples/companion_radio/ui-lvgl/StorageScreen.h index f3993a98..e67b03f5 100644 --- a/examples/companion_radio/ui-lvgl/StorageScreen.h +++ b/examples/companion_radio/ui-lvgl/StorageScreen.h @@ -482,6 +482,9 @@ void UITask::usbPoll() { restartScreen("The computer has given the SD card back."); 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(); if (host == s_host) return; s_host = host; @@ -499,7 +502,7 @@ void UITask::usbPoll() { void UITask::usbTap(bool drive) { using namespace usbview; if (s_overlay) { lv_obj_delete_async(s_overlay); s_overlay = nullptr; } - if (!drive) return; + if (!drive || (locked() && pinSet())) return; storeview::stopWalk(); if (mapview::s_dl.active()) mapDownloadStop(); if (!lvport::usbDriveStart()) { showToast("No SD card to share", 3000); return; } diff --git a/examples/companion_radio/ui-lvgl/UITask.cpp b/examples/companion_radio/ui-lvgl/UITask.cpp index 3bd16e3e..e1a20e00 100644 --- a/examples/companion_radio/ui-lvgl/UITask.cpp +++ b/examples/companion_radio/ui-lvgl/UITask.cpp @@ -898,14 +898,6 @@ void UITask::begin(DisplayDriver* display_drv, SensorManager* sensors, NodePrefs buildStatusBar(); applyDisplayPrefs(); // a slider percentage overrides the level main.cpp set 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 showSplash(); // over both; fades out by itself }