Return correct app data dir from zygote params
This commit is contained in:
parent
ed3612570c
commit
7a5f7181a8
|
|
@ -33,6 +33,7 @@ import org.lsposed.lspd.hooker.CrashDumpHooker;
|
||||||
import org.lsposed.lspd.hooker.HandleSystemServerProcessHooker;
|
import org.lsposed.lspd.hooker.HandleSystemServerProcessHooker;
|
||||||
import org.lsposed.lspd.hooker.LoadedApkCtorHooker;
|
import org.lsposed.lspd.hooker.LoadedApkCtorHooker;
|
||||||
import org.lsposed.lspd.hooker.OpenDexFileHooker;
|
import org.lsposed.lspd.hooker.OpenDexFileHooker;
|
||||||
|
import org.lsposed.lspd.impl.LSPosedContext;
|
||||||
import org.lsposed.lspd.service.ILSPApplicationService;
|
import org.lsposed.lspd.service.ILSPApplicationService;
|
||||||
import org.lsposed.lspd.util.Utils;
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
|
|
@ -74,11 +75,14 @@ public class Startup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initXposed(boolean isSystem, String processName, ILSPApplicationService service) {
|
public static void initXposed(boolean isSystem, String processName, String appDir, ILSPApplicationService service) {
|
||||||
// init logger
|
// init logger
|
||||||
ApplicationServiceClient.Init(service, processName);
|
ApplicationServiceClient.Init(service, processName);
|
||||||
XposedBridge.initXResources();
|
XposedBridge.initXResources();
|
||||||
XposedInit.startsSystemServer = isSystem;
|
XposedInit.startsSystemServer = isSystem;
|
||||||
|
LSPosedContext.isSystemServer = isSystem;
|
||||||
|
LSPosedContext.appDir = appDir;
|
||||||
|
LSPosedContext.processName = processName;
|
||||||
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,11 @@ import io.github.libxposed.XposedModuleInterface;
|
||||||
|
|
||||||
public class LSPosedContext extends XposedContext {
|
public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
public static final String TAG = "LSPosedContext";
|
private static final String TAG = "LSPosedContext";
|
||||||
public static final int PER_USER_RANGE = 100000;
|
private static final int PER_USER_RANGE = 100000;
|
||||||
|
public static boolean isSystemServer;
|
||||||
|
public static String appDir;
|
||||||
|
public static String processName;
|
||||||
|
|
||||||
static final Set<XposedModule> modules = ConcurrentHashMap.newKeySet();
|
static final Set<XposedModule> modules = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
|
@ -274,7 +277,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getDataDir() {
|
public File getDataDir() {
|
||||||
throw new AbstractMethodError();
|
return new File(appDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
-keepclasseswithmembers class org.lsposed.lspd.core.Main {
|
-keepclasseswithmembers class org.lsposed.lspd.core.Main {
|
||||||
public static void forkCommon(boolean, java.lang.String, android.os.IBinder);
|
public static void forkCommon(boolean, java.lang.String, java.lang.String, android.os.IBinder);
|
||||||
}
|
}
|
||||||
-keepclasseswithmembers,includedescriptorclasses class * {
|
-keepclasseswithmembers,includedescriptorclasses class * {
|
||||||
native <methods>;
|
native <methods>;
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import org.lsposed.lspd.BuildConfig;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void forkCommon(boolean isSystem, String niceName, IBinder binder) {
|
public static void forkCommon(boolean isSystem, String niceName, String appDir, IBinder binder) {
|
||||||
Startup.initXposed(isSystem, niceName, ILSPApplicationService.Stub.asInterface(binder));
|
Startup.initXposed(isSystem, niceName, appDir, ILSPApplicationService.Stub.asInterface(binder));
|
||||||
if ((niceName.equals(BuildConfig.MANAGER_INJECTED_PKG_NAME) || niceName.equals(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME))
|
if ((niceName.equals(BuildConfig.MANAGER_INJECTED_PKG_NAME) || niceName.equals(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME))
|
||||||
&& ParasiticManagerHooker.start()) {
|
&& ParasiticManagerHooker.start()) {
|
||||||
Utils.logI("Loaded manager, skipping next steps");
|
Utils.logI("Loaded manager, skipping next steps");
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ namespace lspd {
|
||||||
std::string magiskPath;
|
std::string magiskPath;
|
||||||
|
|
||||||
jstring nice_name = nullptr;
|
jstring nice_name = nullptr;
|
||||||
|
jstring app_dir = nullptr;
|
||||||
|
|
||||||
void onModuleLoaded() {
|
void onModuleLoaded() {
|
||||||
LOGI("onModuleLoaded: welcome to LSPosed!");
|
LOGI("onModuleLoaded: welcome to LSPosed!");
|
||||||
|
|
@ -58,6 +59,7 @@ namespace lspd {
|
||||||
jboolean *,
|
jboolean *,
|
||||||
jboolean *) {
|
jboolean *) {
|
||||||
nice_name = *_nice_name;
|
nice_name = *_nice_name;
|
||||||
|
app_dir = *_app_data_dir;
|
||||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid, *gids,
|
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid, *gids,
|
||||||
nice_name,
|
nice_name,
|
||||||
*start_child_zygote,
|
*start_child_zygote,
|
||||||
|
|
@ -66,7 +68,7 @@ namespace lspd {
|
||||||
|
|
||||||
void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
|
void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env, nice_name);
|
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env, nice_name, app_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
|
void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
|
||||||
|
|
@ -93,6 +95,7 @@ namespace lspd {
|
||||||
jboolean *,
|
jboolean *,
|
||||||
jboolean *) {
|
jboolean *) {
|
||||||
nice_name = *_nice_name;
|
nice_name = *_nice_name;
|
||||||
|
app_dir = *_app_data_dir;
|
||||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid, *gids,
|
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid, *gids,
|
||||||
nice_name,
|
nice_name,
|
||||||
*start_child_zygote,
|
*start_child_zygote,
|
||||||
|
|
@ -100,7 +103,7 @@ namespace lspd {
|
||||||
}
|
}
|
||||||
|
|
||||||
void specializeAppProcessPost(JNIEnv *env, jclass) {
|
void specializeAppProcessPost(JNIEnv *env, jclass) {
|
||||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env, nice_name);
|
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env, nice_name, app_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ namespace lspd {
|
||||||
}
|
}
|
||||||
|
|
||||||
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
||||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env_, args->nice_name);
|
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env_, args->nice_name, args->app_data_dir);
|
||||||
if (*allowUnload) api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
if (*allowUnload) api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ namespace lspd {
|
||||||
InitHooks(env);
|
InitHooks(env);
|
||||||
SetupEntryClass(env);
|
SetupEntryClass(env);
|
||||||
FindAndCall(env, "forkCommon",
|
FindAndCall(env, "forkCommon",
|
||||||
"(ZLjava/lang/String;Landroid/os/IBinder;)V",
|
"(ZLjava/lang/String;Ljava/lang/String;Landroid/os/IBinder;)V",
|
||||||
JNI_TRUE, JNI_NewStringUTF(env, "android"), application_binder);
|
JNI_TRUE, JNI_NewStringUTF(env, "android"), nullptr, application_binder);
|
||||||
GetArt(true);
|
GetArt(true);
|
||||||
} else {
|
} else {
|
||||||
LOGI("skipped system server");
|
LOGI("skipped system server");
|
||||||
|
|
@ -188,7 +188,7 @@ namespace lspd {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MagiskLoader::OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name) {
|
MagiskLoader::OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name, jstring app_dir) {
|
||||||
const JUTFString process_name(env, nice_name);
|
const JUTFString process_name(env, nice_name);
|
||||||
auto *instance = Service::instance();
|
auto *instance = Service::instance();
|
||||||
auto binder = skip_ ? ScopedLocalRef<jobject>{env, nullptr}
|
auto binder = skip_ ? ScopedLocalRef<jobject>{env, nullptr}
|
||||||
|
|
@ -219,7 +219,7 @@ namespace lspd {
|
||||||
SetupEntryClass(env);
|
SetupEntryClass(env);
|
||||||
LOGD("Done prepare");
|
LOGD("Done prepare");
|
||||||
FindAndCall(env, "forkCommon",
|
FindAndCall(env, "forkCommon",
|
||||||
"(ZLjava/lang/String;Landroid/os/IBinder;)V",
|
"(ZLjava/lang/String;Ljava/lang/String;Landroid/os/IBinder;)V",
|
||||||
JNI_FALSE, nice_name, binder);
|
JNI_FALSE, nice_name, binder);
|
||||||
LOGD("injected xposed into {}", process_name.get());
|
LOGD("injected xposed into {}", process_name.get());
|
||||||
setAllowUnload(false);
|
setAllowUnload(false);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace lspd {
|
||||||
void OnNativeForkAndSpecializePre(JNIEnv *env, jint uid, jintArray &gids, jstring nice_name,
|
void OnNativeForkAndSpecializePre(JNIEnv *env, jint uid, jintArray &gids, jstring nice_name,
|
||||||
jboolean is_child_zygote, jstring app_data_dir);
|
jboolean is_child_zygote, jstring app_data_dir);
|
||||||
|
|
||||||
void OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name);
|
void OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name, jstring app_dir);
|
||||||
|
|
||||||
void OnNativeForkSystemServerPost(JNIEnv *env);
|
void OnNativeForkSystemServerPost(JNIEnv *env);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue