问题
Android offers a really powerful way to control application process start - it is so called wrapper script. It is a simple shell script named wrap.sh that should be placed in the app installation lib/ directory (one that contains native libraries, if any):
#!/system/bin/sh
my_wrapper_cmd $@
If an app has such script the system won't fork zygote to create hosting process for the application. Instead once user tries to launch app - system invokes that script to start brand new app_process with separate JVM. It is extremely useful if you e.g. want to launch app under Valgrind or do some LD_PRELOAD. (It works only for debuggable APKs, but it doesn't matter for now)
At the moment I'm able to create an APK that contains libs/<my_device_abi>/wrap.sh. Thanks to this snippet. But after installation I see no wrap.sh in device's lib/ folder:
sailfish:/ $ run-as com.example.sergik.ndksample
sailfish:/data/data/com.example.sergik.ndksample $ ls -l lib/
total 40
-rwxr-xr-x 1 system system 13832 1979-11-30 00:00 libnative-lib.so
There are only packaged .so libraries. At the same time APK contains that script. So obviously package manager has skipped it.
And the question: does anyone know how to put my script to device or force package manager to respect it?
P.S. Device is not rooted, and trying to push wrap.sh via run-as won't work since lib/ is owned by the system and application has no priviledges to write some stuff there.
来源:https://stackoverflow.com/questions/44935575/install-application-wrapper-script-wrap-sh