From 53d7149691d18a710415df40c24698d2bd06a639 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Thu, 23 Apr 2026 15:58:11 -0700 Subject: [PATCH] fix(lockscreen): correct main.cpp injection anchor and early-return guard --- .../LockscreenActivity.cpp | 0 .../LockscreenActivity.h | 0 .../LockscreenPlugin.cpp | 0 .../LockscreenPlugin.h | 0 .../LockscreenSettingsPage.cpp | 0 .../LockscreenSettingsPage.h | 0 plugins/{locksreen => lockscreen}/patch.py | 24 ++++++------------- 7 files changed, 7 insertions(+), 17 deletions(-) rename plugins/{locksreen => lockscreen}/LockscreenActivity.cpp (100%) rename plugins/{locksreen => lockscreen}/LockscreenActivity.h (100%) rename plugins/{locksreen => lockscreen}/LockscreenPlugin.cpp (100%) rename plugins/{locksreen => lockscreen}/LockscreenPlugin.h (100%) rename plugins/{locksreen => lockscreen}/LockscreenSettingsPage.cpp (100%) rename plugins/{locksreen => lockscreen}/LockscreenSettingsPage.h (100%) rename plugins/{locksreen => lockscreen}/patch.py (95%) diff --git a/plugins/locksreen/LockscreenActivity.cpp b/plugins/lockscreen/LockscreenActivity.cpp similarity index 100% rename from plugins/locksreen/LockscreenActivity.cpp rename to plugins/lockscreen/LockscreenActivity.cpp diff --git a/plugins/locksreen/LockscreenActivity.h b/plugins/lockscreen/LockscreenActivity.h similarity index 100% rename from plugins/locksreen/LockscreenActivity.h rename to plugins/lockscreen/LockscreenActivity.h diff --git a/plugins/locksreen/LockscreenPlugin.cpp b/plugins/lockscreen/LockscreenPlugin.cpp similarity index 100% rename from plugins/locksreen/LockscreenPlugin.cpp rename to plugins/lockscreen/LockscreenPlugin.cpp diff --git a/plugins/locksreen/LockscreenPlugin.h b/plugins/lockscreen/LockscreenPlugin.h similarity index 100% rename from plugins/locksreen/LockscreenPlugin.h rename to plugins/lockscreen/LockscreenPlugin.h diff --git a/plugins/locksreen/LockscreenSettingsPage.cpp b/plugins/lockscreen/LockscreenSettingsPage.cpp similarity index 100% rename from plugins/locksreen/LockscreenSettingsPage.cpp rename to plugins/lockscreen/LockscreenSettingsPage.cpp diff --git a/plugins/locksreen/LockscreenSettingsPage.h b/plugins/lockscreen/LockscreenSettingsPage.h similarity index 100% rename from plugins/locksreen/LockscreenSettingsPage.h rename to plugins/lockscreen/LockscreenSettingsPage.h diff --git a/plugins/locksreen/patch.py b/plugins/lockscreen/patch.py similarity index 95% rename from plugins/locksreen/patch.py rename to plugins/lockscreen/patch.py index 0185a99..995f2b0 100644 --- a/plugins/locksreen/patch.py +++ b/plugins/lockscreen/patch.py @@ -375,21 +375,11 @@ def patch_main_cpp(repo_dir): path = find_first("main.cpp", repo_dir) content = read_file(path) - if "LockscreenPlugin" in content: - if "shouldLockOnWake" in content or "shouldLockOnPower" in content or "wasInReader" in content: - content = content.replace( - ' const bool wasInReader = APP_STATE.lastSleepFromReader;\n' - ' const bool shouldLock =\n' - ' hasPinSet &&\n' - ' ((lsMode == LockscreenMode::ENABLED) ||\n' - ' (lsMode == LockscreenMode::ON_POWER && !wasInReader) ||\n' - ' (lsMode == LockscreenMode::ON_WAKE && wasInReader));\n', - ' const bool shouldLock = hasPinSet && LockscreenPlugin::shouldLock(lsMode);\n' - ) - write_file(path, content) - print(" main.cpp patched (updated shouldLock call).") - else: - print(" main.cpp already patched, skipping.") + already_has_includes = "LockscreenPlugin" in content + already_has_block = "LockscreenActivity lockAct" in content + + if already_has_includes and already_has_block: + print(" main.cpp already patched, skipping.") return content = content.replace( @@ -430,11 +420,11 @@ def patch_main_cpp(repo_dir): content = content.replace( ' RECENT_BOOKS.loadFromFile();\n' '\n' - ' // Boot to home screen if no book is open', + ' if (HalSystem::isRebootFromPanic())', ' RECENT_BOOKS.loadFromFile();\n' + lockscreen_block + '\n' - ' // Boot to home screen if no book is open' + ' if (HalSystem::isRebootFromPanic())' ) write_file(path, content)