Fix timing and Android 15 support
This pull request addresses critical issues observed in the AdGuard certificate module logs, ensuring proper functionality and compatibility with the Android 14/15 APEX CA directory.
Context and Observed Issues
I noticed that the module often simply didn't apply the changes and, after examining the logs, identified the same errors as in this timing-related issue, as well as another one related to unmounting:
-
Timing Issues:
- The script attempted operations before the
zygote64process was initialized, causing the module to stall in an indefinite loop: - This was due to race conditions where the system was not ready for the operations the module tried to perform.
- The script attempted operations before the
-
Temporary Directory Cleanup Issues:
- Errors occurred during the unmounting and removal of the temporary directory:
rmdir: '/data/local/tmp/adg-ca-copy': Device or resource busy - This was caused by lingering processes keeping the directory in use, leading to improper cleanup.
- Errors occurred during the unmounting and removal of the temporary directory:
Fixes Implemented
-
Timing Fix for zygote64 Initialization
- Added a loop to wait for the
zygote64process before proceeding with critical operations. - Ensures that the module executes only after the system is ready, eliminating timing-related stalls.
- Added a loop to wait for the
-
Enhancements for Android 14 APEX CA Directory Handling
- Improved cleanup logic for the temporary directory:
- Replaced
rm -fwithrm -rffor proper directory removal. - Added a loop to retry unmounting until successful, addressing the "Device or resource busy" error.
- Replaced
- Introduced a reusable
TEMP_DIRvariable for improved readability and easier future maintenance.
- Improved cleanup logic for the temporary directory:
Testing
- Verified the script now waits for
zygote64to initialize before performing operations. - Tested directory creation, mounting, and cleanup, ensuring all resources are properly managed without errors.
- Checked compatibility on Android 15 with APEX CA directories.
Impact
- Reliability: Resolves timing issues for a smooth initialization process.
- Compatibility: Supports Android 14's APEX CA structure effectively.
For some reason this cause my phone to be stuck on boot screen. Using KernelSU-Next with Zygisk Next.
I thought only administrators had the permission to approve, and I was curious so I clicked it. Sorry about that
For some reason this cause my phone to be stuck on boot screen. Using KernelSU-Next with Zygisk Next.
Same to me, OnePlus Ace 3,KernelSU by 5ec1cff
For some reason this cause my phone to be stuck on boot screen. Using KernelSU-Next with Zygisk Next.
It is a question of nonsense, cause magisk modules is only designed for magisk. Ksu has its own rules, even though it might be compatible with some magisk modules.
For some reason this cause my phone to be stuck on boot screen. Using KernelSU-Next with Zygisk Next.
It is a question of nonsense, cause magisk modules is only designed for magisk. Ksu has its own rules, even though it might be compatible with some magisk modules.
Almost all incompatibilities are caused by modules not being designed according to standard templates.
Hello! There's a lot issues with this PR.
First, it will definitely hang on 32-bit devices, and in case that umount permanently fails.
Second, it does some refactoring, not only targets issues.
And at last, if we assume that on some configurations, zygote is being spawned while running this script, not before, then additional research is needed about parent process on that configuration. If it is PID 1, then simply evaluating $(pgrep zygote64) after PID 1's mount, not before in for, should help fix the race.
P.S. KernelSU issues are not relevant to this PR since they are present on master too, see #62
See my previous comment
Seems unvisible.
@larsmartens hey, can you rebase with Android 16 support?
@larsmartens hey, can you rebase with Android 16 support?
You can use https://github.com/ys1231/MoveCertificate