adguardcert icon indicating copy to clipboard operation
adguardcert copied to clipboard

Fix timing and Android 15 support

Open larsmartens opened this issue 1 year ago • 6 comments

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:

  1. Timing Issues:

    • The script attempted operations before the zygote64 process 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.
  2. 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.

Fixes Implemented

  1. Timing Fix for zygote64 Initialization

    • Added a loop to wait for the zygote64 process before proceeding with critical operations.
    • Ensures that the module executes only after the system is ready, eliminating timing-related stalls.
  2. Enhancements for Android 14 APEX CA Directory Handling

    • Improved cleanup logic for the temporary directory:
      • Replaced rm -f with rm -rf for proper directory removal.
      • Added a loop to retry unmounting until successful, addressing the "Device or resource busy" error.
    • Introduced a reusable TEMP_DIR variable for improved readability and easier future maintenance.

Testing

  • Verified the script now waits for zygote64 to 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.

larsmartens avatar Dec 06 '24 21:12 larsmartens

For some reason this cause my phone to be stuck on boot screen. Using KernelSU-Next with Zygisk Next.

Loukious avatar Feb 07 '25 06:02 Loukious

I thought only administrators had the permission to approve, and I was curious so I clicked it. Sorry about that

chengnan049 avatar Feb 07 '25 11:02 chengnan049

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

chengnan049 avatar Feb 07 '25 11:02 chengnan049

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.

sovzzz avatar Apr 06 '25 03:04 sovzzz

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.

chengnan049 avatar Apr 06 '25 03:04 chengnan049

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

sfionov avatar Jul 04 '25 03:07 sfionov

See my previous comment

Seems unvisible.

CanerKaraca23 avatar Nov 19 '25 10:11 CanerKaraca23

@larsmartens hey, can you rebase with Android 16 support?

CanerKaraca23 avatar Nov 19 '25 10:11 CanerKaraca23

@larsmartens hey, can you rebase with Android 16 support?

You can use https://github.com/ys1231/MoveCertificate

chengnan049 avatar Nov 19 '25 12:11 chengnan049