Skip to content

fix: keep KPM install and unload state consistent - #1562

Open
matsuzaka-yuki wants to merge 1 commit into
bmax121:mainfrom
matsuzaka-yuki:fix/kpm-install-unload-consistency
Open

fix: keep KPM install and unload state consistent#1562
matsuzaka-yuki wants to merge 1 commit into
bmax121:mainfrom
matsuzaka-yuki:fix/kpm-install-unload-consistency

Conversation

@matsuzaka-yuki

Copy link
Copy Markdown
Contributor

Summary

In the KPM management flow, uninstall state was inconsistent: installing a module then immediately unloading it left the UI in a stale state, and the persistent file under /data/adb/ap/kpm/<id>/ could remain after the module appeared removed.

This change decouples the install/unload decisions so the UI reflects what actually happened on disk and in the kernel.

Changes

KPModuleViewModel.kt

  • Only call Natives.kernelPatchModuleList() when the kernel actually reports a nonzero module count.
  • Skip Natives.kernelPatchModuleInfo(id) for modules that are not in the loaded kernel list; freshly installed (not yet rebooted) modules no longer trigger a live kernel lookup.

KPM.kt

  • After an install, only mark the list for refresh on next entry / manual refresh (module takes effect after reboot). Do not immediately re-query the kernel for a module that is not loaded yet.
  • Serialize installs with a mutex so rapid taps cannot delete each other's shared temporary staging directory.
  • On uninstall, decouple live kernel unload from persistent file removal:
    • Try unloading the running instance.
    • Independently remove and verify the persistence directory (rm -rf ... && test ! -e ...).
    • Refresh the list whenever the persistent file was actually removed, even if the live kernel unload returned nonzero.

Why

KPM installed via the "Install" action is only loaded by the boot-time loader after reboot. Re-querying the kernel for it immediately after install (and the combined uninstall condition) made the UI show the module as present/removed incorrectly, and could leave a stale /data/adb/ap/kpm/<id>/<id>.kpm entry after uninstall.

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.

1 participant