Wait zygote socket before launching daemon (#1748)
This commit is contained in:
parent
dc6a599f00
commit
e40596f9f8
|
|
@ -26,5 +26,13 @@ fi
|
||||||
|
|
||||||
mount tmpfs -t tmpfs /data/resource-cache
|
mount tmpfs -t tmpfs /data/resource-cache
|
||||||
|
|
||||||
|
if [ ! -S "/dev/socket/zygote" ]; then
|
||||||
|
timeout 1 inotifyd - /dev/socket:near | while read -r; do
|
||||||
|
if [ -S "/dev/socket/zygote" ]; then
|
||||||
|
touch /dev/socket&
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
exec /system/bin/app_process $java_options /system/bin --nice-name=lspd org.lsposed.lspd.Main "$@" >/dev/null 2>&1
|
exec /system/bin/app_process $java_options /system/bin --nice-name=lspd org.lsposed.lspd.Main "$@" >/dev/null 2>&1
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,7 @@ namespace lspd {
|
||||||
JNI_CallStaticVoidMethod(env_, process, set_argv0, JNI_NewStringUTF(env_, "system_server"));
|
JNI_CallStaticVoidMethod(env_, process, set_argv0, JNI_NewStringUTF(env_, "system_server"));
|
||||||
}
|
}
|
||||||
Context::GetInstance()->OnNativeForkSystemServerPost(env_);
|
Context::GetInstance()->OnNativeForkSystemServerPost(env_);
|
||||||
|
if (*allowUnload) api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,12 +207,11 @@ namespace lspd {
|
||||||
InstallInlineHooks();
|
InstallInlineHooks();
|
||||||
Init(env);
|
Init(env);
|
||||||
FindAndCall(env, "forkSystemServerPost", "(Landroid/os/IBinder;)V", application_binder);
|
FindAndCall(env, "forkSystemServerPost", "(Landroid/os/IBinder;)V", application_binder);
|
||||||
} else skip_ = true;
|
} else {
|
||||||
|
LOGI("skipped system server");
|
||||||
|
GetArt(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (skip_) [[unlikely]] {
|
|
||||||
LOGW("skipped system server");
|
|
||||||
}
|
|
||||||
setAllowUnload(skip_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::OnNativeForkAndSpecializePre(JNIEnv *env,
|
void Context::OnNativeForkAndSpecializePre(JNIEnv *env,
|
||||||
|
|
@ -277,7 +276,7 @@ namespace lspd {
|
||||||
} else {
|
} else {
|
||||||
auto context = Context::ReleaseInstance();
|
auto context = Context::ReleaseInstance();
|
||||||
auto service = Service::ReleaseInstance();
|
auto service = Service::ReleaseInstance();
|
||||||
GetArt().reset();
|
GetArt(true);
|
||||||
LOGD("skipped %s", process_name.get());
|
LOGD("skipped %s", process_name.get());
|
||||||
setAllowUnload(true);
|
setAllowUnload(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace lspd {
|
||||||
art::thread_list::ScopedSuspendAll::Setup(handle_libart);
|
art::thread_list::ScopedSuspendAll::Setup(handle_libart);
|
||||||
art::gc::ScopedGCCriticalSection::Setup(handle_libart);
|
art::gc::ScopedGCCriticalSection::Setup(handle_libart);
|
||||||
art::jit::jit_code_cache::Setup(handle_libart);
|
art::jit::jit_code_cache::Setup(handle_libart);
|
||||||
GetArt().reset();
|
GetArt(true);
|
||||||
LOGD("Inline hooks installed");
|
LOGD("Inline hooks installed");
|
||||||
}
|
}
|
||||||
} // namespace lspd
|
} // namespace lspd
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,11 @@
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
std::unique_ptr<SymbolCache> symbol_cache = std::make_unique<SymbolCache>();
|
std::unique_ptr<SymbolCache> symbol_cache = std::make_unique<SymbolCache>();
|
||||||
|
|
||||||
std::unique_ptr<const SandHook::ElfImg> &GetArt() {
|
std::unique_ptr<const SandHook::ElfImg> &GetArt(bool release) {
|
||||||
static std::unique_ptr<const SandHook::ElfImg> kArtImg = nullptr;
|
static std::unique_ptr<const SandHook::ElfImg> kArtImg = nullptr;
|
||||||
if (!kArtImg) {
|
if (release) {
|
||||||
|
kArtImg.reset();
|
||||||
|
} else if (!kArtImg) {
|
||||||
kArtImg = std::make_unique<SandHook::ElfImg>(kLibArtName);
|
kArtImg = std::make_unique<SandHook::ElfImg>(kLibArtName);
|
||||||
}
|
}
|
||||||
return kArtImg;
|
return kArtImg;
|
||||||
|
|
@ -77,7 +79,7 @@ namespace lspd {
|
||||||
symbol_cache->do_dlopen = SandHook::ElfImg("/linker").getSymbAddress<void *>(
|
symbol_cache->do_dlopen = SandHook::ElfImg("/linker").getSymbAddress<void *>(
|
||||||
"__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv");
|
"__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv");
|
||||||
if (!ok) [[unlikely]] {
|
if (!ok) [[unlikely]] {
|
||||||
GetArt().reset();
|
GetArt(true);
|
||||||
LOGE("Init symbol cache failed");
|
LOGE("Init symbol cache failed");
|
||||||
} else {
|
} else {
|
||||||
symbol_cache->initialized.test_and_set(std::memory_order_relaxed);
|
symbol_cache->initialized.test_and_set(std::memory_order_relaxed);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ namespace lspd {
|
||||||
|
|
||||||
void InitSymbolCache(SymbolCache *other);
|
void InitSymbolCache(SymbolCache *other);
|
||||||
|
|
||||||
std::unique_ptr<const SandHook::ElfImg> &GetArt();
|
std::unique_ptr<const SandHook::ElfImg> &GetArt(bool release=false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //LSPOSED_SYMBOL_CACHE_H
|
#endif //LSPOSED_SYMBOL_CACHE_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue