Skip to content

Prevent stale Magisk and KernelSU hooks from polling forever - #25

Open
LIghtJUNction wants to merge 1 commit into
Chainfire:masterfrom
LIghtJUNction:fix/bounded-boot-hook-wait
Open

Prevent stale Magisk and KernelSU hooks from polling forever#25
LIghtJUNction wants to merge 1 commit into
Chainfire:masterfrom
LIghtJUNction:fix/bounded-boot-hook-wait

Conversation

@LIghtJUNction

Copy link
Copy Markdown

Summary

  • preserve the existing 100 ms fast wait for the first 5 seconds, then fall back to one check per second
  • remove both hooks when boot has completed and the device-protected LiveBoot launcher is still absent
  • cap the fallback wait at 180 seconds so a boot that never completes cannot leave pollers alive for the entire uptime
  • apply the same behavior to the duplicated Magisk and KernelSU hook paths
  • add a script marker so existing unbounded hooks are detected and regenerated the next time LiveBoot is opened

The cleanup deliberately waits for sys.boot_completed rather than consulting PackageManager or parsing /data/system/packages.list during post-fs-data. At boot completion, device-protected storage should be available; before then, a missing files directory is not sufficient evidence that the app was uninstalled. If boot never completes, the hard timeout exits without deleting anything.

Fixes #24.

Testing

  • ./gradlew :liveBootAni2:assembleDebug --stacktrace
  • parsed all 15 Java source files successfully
  • shellcheck -s sh and Android /system/bin/sh -n on the generated hook shape
  • exercised the hook behavior with Android /system/bin/sh for:
    • launcher already present
    • launcher appearing during the fast wait
    • stale hook after boot completion (both hooks removed)
    • boot never completing (bounded exit without removal)

Copilot AI lite review requested due to automatic review settings August 27, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KernelSU hooks poll forever after the APK is uninstalled normally

2 participants