Add a debugging switch to enable instant modules loading
This commit is contained in:
parent
a362c984c9
commit
a0d713715d
|
|
@ -14,18 +14,21 @@ import static com.elderdrivers.riru.xposed.util.FileUtils.getDataPathPrefix;
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
public class Main implements KeepAll {
|
public class Main implements KeepAll {
|
||||||
|
|
||||||
|
// private static String sForkAndSpecializePramsStr = "";
|
||||||
|
// private static String sForkSystemServerPramsStr = "";
|
||||||
|
public static String sAppDataDir = "";
|
||||||
|
public static String sAppProcessName = "";
|
||||||
|
/**
|
||||||
|
* Whether do bootstrap hooking only once
|
||||||
|
*/
|
||||||
|
private static boolean sIsGlobalMode = false;
|
||||||
/**
|
/**
|
||||||
* When set to true, install bootstrap hooks and loadModules
|
* When set to true, install bootstrap hooks and loadModules
|
||||||
* for each process when it starts.
|
* for each process when it starts.
|
||||||
* This means you can deactivate or activate every module
|
* This means you can deactivate or activate every module
|
||||||
* for the process you restart without rebooting.
|
* for the process you restart without rebooting.
|
||||||
*/
|
*/
|
||||||
private static final boolean DYNAMIC_LOAD_MODULES = false;
|
private static boolean sIsDynamicModules = false;
|
||||||
// private static String sForkAndSpecializePramsStr = "";
|
|
||||||
// private static String sForkSystemServerPramsStr = "";
|
|
||||||
public static String sAppDataDir = "";
|
|
||||||
public static String sAppProcessName = "";
|
|
||||||
private static boolean sIsGlobalMode = false;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
init(Build.VERSION.SDK_INT);
|
init(Build.VERSION.SDK_INT);
|
||||||
|
|
@ -41,7 +44,8 @@ public class Main implements KeepAll {
|
||||||
int[][] rlimits, int mountExternal, String seInfo,
|
int[][] rlimits, int mountExternal, String seInfo,
|
||||||
String niceName, int[] fdsToClose, int[] fdsToIgnore,
|
String niceName, int[] fdsToClose, int[] fdsToIgnore,
|
||||||
boolean startChildZygote, String instructionSet,
|
boolean startChildZygote, String instructionSet,
|
||||||
String appDataDir, boolean isGlobalMode) {
|
String appDataDir, boolean isGlobalMode,
|
||||||
|
boolean isDynamicModules) {
|
||||||
// sForkAndSpecializePramsStr = String.format(
|
// sForkAndSpecializePramsStr = String.format(
|
||||||
// "Zygote#forkAndSpecialize(%d, %d, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s)",
|
// "Zygote#forkAndSpecialize(%d, %d, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s)",
|
||||||
// uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
// uid, gid, Arrays.toString(gids), debugFlags, Arrays.toString(rlimits),
|
||||||
|
|
@ -49,18 +53,25 @@ public class Main implements KeepAll {
|
||||||
// Arrays.toString(fdsToIgnore), startChildZygote, instructionSet, appDataDir);
|
// Arrays.toString(fdsToIgnore), startChildZygote, instructionSet, appDataDir);
|
||||||
sAppDataDir = appDataDir;
|
sAppDataDir = appDataDir;
|
||||||
sIsGlobalMode = isGlobalMode;
|
sIsGlobalMode = isGlobalMode;
|
||||||
if (!DYNAMIC_LOAD_MODULES && isGlobalMode) {
|
sIsDynamicModules = isDynamicModules;
|
||||||
|
if (isGlobalMode) {
|
||||||
Router.onProcessForked(false);
|
Router.onProcessForked(false);
|
||||||
}
|
}
|
||||||
|
if (!sIsDynamicModules) {
|
||||||
|
Router.loadModulesSafely();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void forkAndSpecializePost(int pid, String appDataDir) {
|
public static void forkAndSpecializePost(int pid, String appDataDir) {
|
||||||
// Utils.logD(sForkAndSpecializePramsStr + " = " + pid);
|
// Utils.logD(sForkAndSpecializePramsStr + " = " + pid);
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// in app process
|
// in app process
|
||||||
if (DYNAMIC_LOAD_MODULES || !sIsGlobalMode) {
|
if (!sIsGlobalMode) {
|
||||||
Router.onProcessForked(false);
|
Router.onProcessForked(false);
|
||||||
}
|
}
|
||||||
|
if (sIsDynamicModules) {
|
||||||
|
Router.loadModulesSafely();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// in zygote process, res is child zygote pid
|
// in zygote process, res is child zygote pid
|
||||||
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
|
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
|
||||||
|
|
@ -80,6 +91,7 @@ public class Main implements KeepAll {
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// in system_server process
|
// in system_server process
|
||||||
Router.onProcessForked(true);
|
Router.onProcessForked(true);
|
||||||
|
Router.loadModulesSafely();
|
||||||
} else {
|
} else {
|
||||||
// in zygote process, res is child zygote pid
|
// in zygote process, res is child zygote pid
|
||||||
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
|
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,21 @@ public class Router {
|
||||||
// Initialize the Xposed framework and modules
|
// Initialize the Xposed framework and modules
|
||||||
try {
|
try {
|
||||||
XposedInit.initForZygote(isSystem);
|
XposedInit.initForZygote(isSystem);
|
||||||
// FIXME some coredomain app can't reading modules.list
|
|
||||||
XposedInit.loadModules();
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Utils.logE("Errors during Xposed initialization", t);
|
Utils.logE("Errors during Xposed initialization", t);
|
||||||
XposedBridge.disableHooks = true;
|
XposedBridge.disableHooks = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadModulesSafely() {
|
||||||
|
try {
|
||||||
|
// FIXME some coredomain app can't reading modules.list
|
||||||
|
XposedInit.loadModules();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Utils.logE("error loading module list", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void startBootstrapHook(boolean isSystem) {
|
public static void startBootstrapHook(boolean isSystem) {
|
||||||
Utils.logD("startBootstrapHook starts: isSystem = " + isSystem);
|
Utils.logD("startBootstrapHook starts: isSystem = " + isSystem);
|
||||||
ClassLoader classLoader = XposedBridge.BOOTCLASSLOADER;
|
ClassLoader classLoader = XposedBridge.BOOTCLASSLOADER;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
version "v0.2.9.6_beta"
|
version "v0.2.9.7_beta"
|
||||||
extensions["module_name"] = "EdXposed"
|
extensions["module_name"] = "EdXposed"
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,17 @@
|
||||||
#define WHITE_LIST_PATH "/data/misc/riru/modules/edxposed/whitelist/"
|
#define WHITE_LIST_PATH "/data/misc/riru/modules/edxposed/whitelist/"
|
||||||
#define USE_WHITE_LIST "/data/misc/riru/modules/edxposed/usewhitelist"
|
#define USE_WHITE_LIST "/data/misc/riru/modules/edxposed/usewhitelist"
|
||||||
#define GLOBAL_MODE "/data/misc/riru/modules/edxposed/forceglobal"
|
#define GLOBAL_MODE "/data/misc/riru/modules/edxposed/forceglobal"
|
||||||
|
#define DYNAMIC_MODULES "/data/misc/riru/modules/edxposed/dynamicmodules"
|
||||||
|
|
||||||
static char package_name[256];
|
static char package_name[256];
|
||||||
static bool global_mode = false;
|
static bool global_mode = false;
|
||||||
|
static bool dynamic_modules = false;
|
||||||
static bool inited = false;
|
static bool inited = false;
|
||||||
|
|
||||||
void initOnce() {
|
void initOnce() {
|
||||||
if (!inited) {
|
if (!inited) {
|
||||||
global_mode = access(GLOBAL_MODE, F_OK) == 0;
|
global_mode = access(GLOBAL_MODE, F_OK) == 0;
|
||||||
|
dynamic_modules = access(DYNAMIC_MODULES, F_OK) == 0;
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +72,12 @@ int is_app_need_hook(JNIEnv *env, jstring appDataDir) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_global_mode() {
|
bool is_global_mode() {
|
||||||
initOnce();
|
initOnce();
|
||||||
return global_mode;
|
return global_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_dynamic_modules() {
|
||||||
|
initOnce();
|
||||||
|
return dynamic_modules;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
int is_app_need_hook(JNIEnv *env, jstring appDataDir);
|
int is_app_need_hook(JNIEnv *env, jstring appDataDir);
|
||||||
|
|
||||||
int is_global_mode();
|
bool is_global_mode();
|
||||||
|
|
||||||
|
bool is_dynamic_modules();
|
||||||
|
|
||||||
#endif //EDXPOSED_CONFIG_MANAGER_H
|
#endif //EDXPOSED_CONFIG_MANAGER_H
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,10 @@ void onNativeForkAndSpecializePre(JNIEnv *env, jclass clazz,
|
||||||
}
|
}
|
||||||
prepareJavaEnv(env);
|
prepareJavaEnv(env);
|
||||||
findAndCall(env, "forkAndSpecializePre",
|
findAndCall(env, "forkAndSpecializePre",
|
||||||
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z)V",
|
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;ZZ)V",
|
||||||
uid, gid, gids, runtime_flags, rlimits,
|
uid, gid, gids, runtime_flags, rlimits,
|
||||||
_mount_external, se_info, se_name, fdsToClose, fdsToIgnore,
|
_mount_external, se_info, se_name, fdsToClose, fdsToIgnore,
|
||||||
is_child_zygote, instructionSet, appDataDir, is_global_mode());
|
is_child_zygote, instructionSet, appDataDir, is_global_mode(), is_dynamic_modules());
|
||||||
}
|
}
|
||||||
|
|
||||||
int onNativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
|
int onNativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ LATESTARTSERVICE=false
|
||||||
|
|
||||||
print_modname() {
|
print_modname() {
|
||||||
ui_print "************************************"
|
ui_print "************************************"
|
||||||
ui_print " Riru - Ed Xposed v0.2.9.6 "
|
ui_print " Riru - Ed Xposed v0.2.9.7 "
|
||||||
ui_print "************************************"
|
ui_print "************************************"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
id=riru_edxposed
|
id=riru_edxposed
|
||||||
name=Riru - Ed Xposed
|
name=Riru - Ed Xposed
|
||||||
version=v0.2.9.6_beta
|
version=v0.2.9.7_beta
|
||||||
versionCode=1
|
versionCode=1
|
||||||
author=givein2u
|
author=givein2u
|
||||||
description=Magisk version of Xposed. Require Riru - Core installed.
|
description=Magisk version of Xposed. Require Riru - Core installed.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name=Ed Xposed
|
name=Ed Xposed
|
||||||
version=v0.2.9.6_beta
|
version=v0.2.9.7_beta
|
||||||
versionCode=1
|
versionCode=1
|
||||||
author=givein2u
|
author=givein2u
|
||||||
description=Elder driver Xposed for Android Pie. Require Riru - Core installed.
|
description=Elder driver Xposed for Android Pie. Require Riru - Core installed.
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version=90.0-0.2.9.6 (by Elder Driver)
|
version=90.0-0.2.9.7 (by Elder Driver)
|
||||||
arch=arm64
|
arch=arm64
|
||||||
minsdk=23
|
minsdk=23
|
||||||
maxsdk=28
|
maxsdk=28
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue