fix(lockscreen): correct main.cpp injection anchor and early-return guard
This commit is contained in:
@@ -375,21 +375,11 @@ def patch_main_cpp(repo_dir):
|
|||||||
path = find_first("main.cpp", repo_dir)
|
path = find_first("main.cpp", repo_dir)
|
||||||
content = read_file(path)
|
content = read_file(path)
|
||||||
|
|
||||||
if "LockscreenPlugin" in content:
|
already_has_includes = "LockscreenPlugin" in content
|
||||||
if "shouldLockOnWake" in content or "shouldLockOnPower" in content or "wasInReader" in content:
|
already_has_block = "LockscreenActivity lockAct" in content
|
||||||
content = content.replace(
|
|
||||||
' const bool wasInReader = APP_STATE.lastSleepFromReader;\n'
|
if already_has_includes and already_has_block:
|
||||||
' const bool shouldLock =\n'
|
print(" main.cpp already patched, skipping.")
|
||||||
' 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.")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
@@ -430,11 +420,11 @@ def patch_main_cpp(repo_dir):
|
|||||||
content = content.replace(
|
content = content.replace(
|
||||||
' RECENT_BOOKS.loadFromFile();\n'
|
' RECENT_BOOKS.loadFromFile();\n'
|
||||||
'\n'
|
'\n'
|
||||||
' // Boot to home screen if no book is open',
|
' if (HalSystem::isRebootFromPanic())',
|
||||||
' RECENT_BOOKS.loadFromFile();\n'
|
' RECENT_BOOKS.loadFromFile();\n'
|
||||||
+ lockscreen_block
|
+ lockscreen_block
|
||||||
+ '\n'
|
+ '\n'
|
||||||
' // Boot to home screen if no book is open'
|
' if (HalSystem::isRebootFromPanic())'
|
||||||
)
|
)
|
||||||
|
|
||||||
write_file(path, content)
|
write_file(path, content)
|
||||||
Reference in New Issue
Block a user