diff --git a/edxp-common/build.gradle b/edxp-common/build.gradle index 4109bcedd40..f501d35514d 100644 --- a/edxp-common/build.gradle +++ b/edxp-common/build.gradle @@ -21,7 +21,7 @@ android { dependencies { compileOnly project(':hiddenapi-stubs') - implementation project(':xposed-bridge') + api project(':xposed-bridge') compileOnly project(':dexmaker') api "androidx.annotation:annotation:1.1.0-rc01" } diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/HandleBindAppHooker.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/HandleBindAppHooker.java index c203f31be26..2174fff8ca9 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/HandleBindAppHooker.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/HandleBindAppHooker.java @@ -4,7 +4,10 @@ import com.elderdrivers.riru.edxp._hooker.impl.HandleBindApp; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class HandleBindAppHooker implements KeepMembers { public static String className = "android.app.ActivityThread"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/LoadedApkConstructorHooker.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/LoadedApkConstructorHooker.java index d499f2bf9a4..14845299c63 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/LoadedApkConstructorHooker.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/LoadedApkConstructorHooker.java @@ -8,7 +8,10 @@ import com.elderdrivers.riru.edxp._hooker.impl.LoadedApkCstr; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class LoadedApkConstructorHooker implements KeepMembers { public static String className = "android.app.LoadedApk"; public static String methodName = ""; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/OnePlusWorkAroundHooker.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/OnePlusWorkAroundHooker.java index 2fb6b3d03b7..8fea63fe30b 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/OnePlusWorkAroundHooker.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/OnePlusWorkAroundHooker.java @@ -5,7 +5,10 @@ import com.elderdrivers.riru.edxp.core.yahfa.HookMain; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.MIDDLE) public class OnePlusWorkAroundHooker implements KeepMembers { static { diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker11.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker11.java index 965fc38aefc..e47facfb420 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker11.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/StartBootstrapServicesHooker11.java @@ -4,7 +4,10 @@ import com.elderdrivers.riru.edxp._hooker.impl.StartBootstrapServices; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class StartBootstrapServicesHooker11 implements KeepMembers { public static String className = "com.android.server.SystemServer"; public static String methodName = "startBootstrapServices"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/SystemMainHooker.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/SystemMainHooker.java index 544fe5ea4b3..be3a46a8a37 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/SystemMainHooker.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/_hooker/yahfa/SystemMainHooker.java @@ -6,7 +6,10 @@ import com.elderdrivers.riru.edxp._hooker.impl.SystemMain; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class SystemMainHooker implements KeepMembers { public static String className = "android.app.ActivityThread"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java index 16e169f06fd..b51097f3255 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java @@ -1,10 +1,8 @@ package com.elderdrivers.riru.edxp.art; import com.elderdrivers.riru.common.KeepAll; -import com.elderdrivers.riru.edxp.core.Yahfa; import java.lang.reflect.Member; -import java.util.function.Consumer; import de.robv.android.xposed.PendingHooks; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/Heap.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/Heap.java index 8cff42756b6..68e9ce051d7 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/Heap.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/Heap.java @@ -1,7 +1,5 @@ package com.elderdrivers.riru.edxp.art; -import java.lang.reflect.Member; - public class Heap { public static native int waitForGcToComplete(long thread); diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Main.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Main.java index 634dde34cca..06c41d36fab 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Main.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/core/Main.java @@ -160,6 +160,7 @@ public Void run() { }); } + // TODO do this earlier? private static boolean isBlackListedProcess(int uid) { return ProcessHelper.isIsolated(uid) || ProcessHelper.isRELROUpdater(uid) diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/deopt/InlinedMethodCallers.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/deopt/InlinedMethodCallers.java index daf891b589d..6a6a33852c9 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/deopt/InlinedMethodCallers.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/deopt/InlinedMethodCallers.java @@ -2,6 +2,9 @@ import java.util.HashMap; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; + /** * Providing a whitelist of methods which are the callers of the target methods we want to hook. * Because the target methods are inlined into the callers, we deoptimize the callers to @@ -10,6 +13,7 @@ * Only for methods which are included in pre-compiled framework codes. * TODO recompile system apps and priv-apps since their original dex files are available */ +@ApiSensitive(Level.MIDDLE) public class InlinedMethodCallers { public static final String KEY_BOOT_IMAGE = "boot_image"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/Hook.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/Hook.java deleted file mode 100644 index 06d65505652..00000000000 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/Hook.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.elderdrivers.riru.edxp.entry; - -public interface Hook { -} diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/HookImpl.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/HookImpl.java deleted file mode 100644 index 6dae3896ec6..00000000000 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/entry/HookImpl.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.elderdrivers.riru.edxp.entry; - -public class HookImpl implements Hook { - -} diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/ProcessHelper.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/ProcessHelper.java index 6018a1ea148..4423f165c78 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/ProcessHelper.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/ProcessHelper.java @@ -1,7 +1,10 @@ package com.elderdrivers.riru.edxp.framework; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.MIDDLE) public class ProcessHelper { static { diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/Zygote.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/Zygote.java index 9ca7606cdd0..880fa7588a2 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/Zygote.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/framework/Zygote.java @@ -3,7 +3,10 @@ import com.elderdrivers.riru.edxp.util.Utils; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class Zygote { // prevent from fatal error caused by holding not whitelisted file descriptors when forking zygote diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/SliceProviderFix.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/SliceProviderFix.java index eadb33c57f1..d2d4e4698ab 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/SliceProviderFix.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/SliceProviderFix.java @@ -4,7 +4,10 @@ import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class SliceProviderFix { public static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/BaseRouter.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/BaseRouter.java index 06776e13e95..996843e775f 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/BaseRouter.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/proxy/BaseRouter.java @@ -28,6 +28,8 @@ import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.XposedInit; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; public abstract class BaseRouter implements Router { @@ -94,6 +96,7 @@ public String parsePackageName(String appDataDir) { } + @ApiSensitive(Level.LOW) public void startBootstrapHook(boolean isSystem) { Utils.logD("startBootstrapHook starts: isSystem = " + isSystem); ClassLoader classLoader = BaseRouter.class.getClassLoader(); @@ -143,6 +146,7 @@ public void startSystemServerHook() { } } + @ApiSensitive(Level.LOW) public void startWorkAroundHook() { ClassLoader classLoader = BaseRouter.class.getClassLoader(); if (useXposedApi) { diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassLoaderUtils.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassLoaderUtils.java index 75aa4cbccad..4ef454352f8 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassLoaderUtils.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassLoaderUtils.java @@ -15,7 +15,10 @@ import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) public class ClassLoaderUtils { public static final String DEXPATH = "/system/framework/edxp.jar:/system/framework/eddalvikdx.jar:/system/framework/eddexmaker.jar"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassUtils.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassUtils.java index a5eb8c9e320..297c20ad85d 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassUtils.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ClassUtils.java @@ -7,9 +7,12 @@ import java.lang.reflect.Modifier; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; public class ClassUtils { + @ApiSensitive(Level.MIDDLE) public static int getClassStatus(Class clazz, boolean isUnsigned) { if (clazz == null) { return 0; @@ -25,8 +28,9 @@ public static int getClassStatus(Class clazz, boolean isUnsigned) { /** * 5.0-8.0: kInitialized = 10 int * 8.1: kInitialized = 11 int - * 9.0: kInitialized = 14 uint8_t + * 9.0+: kInitialized = 14 uint8_t */ + @ApiSensitive(Level.MIDDLE) public static boolean isInitialized(Class clazz) { if (Build.VERSION.SDK_INT >= 28) { return getClassStatus(clazz, true) == 14; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/DexUtils.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/DexUtils.java index eea9f75cfe3..2233b6a48ce 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/DexUtils.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/DexUtils.java @@ -8,10 +8,13 @@ import dalvik.system.BaseDexClassLoader; import dalvik.system.DexClassLoader; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; /** * For 6.0 only. */ +@ApiSensitive(Level.LOW) @TargetApi(Build.VERSION_CODES.M) public class DexUtils { diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ProcessUtils.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ProcessUtils.java index b0e8edaa541..01b7054d537 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ProcessUtils.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/ProcessUtils.java @@ -8,6 +8,10 @@ import java.io.FileInputStream; import java.io.InputStreamReader; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; + +@ApiSensitive(Level.LOW) public class ProcessUtils { // Copied from UserHandle, indicates range of uids allocated for a user. diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Unsafe.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Unsafe.java index ab788317198..a04330f8134 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Unsafe.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Unsafe.java @@ -21,6 +21,10 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; + +@ApiSensitive(Level.LOW) public final class Unsafe { private static final String TAG = "Unsafe"; diff --git a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Utils.java b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Utils.java index e6bcb84531d..b1fa37418c1 100644 --- a/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Utils.java +++ b/edxp-common/src/main/java/com/elderdrivers/riru/edxp/util/Utils.java @@ -5,6 +5,8 @@ import com.elderdrivers.riru.edxp.common.BuildConfig; import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; public class Utils { @@ -45,6 +47,7 @@ public static void logE(String msg, Throwable throwable) { Log.e(LOG_TAG, msg, throwable); } + @ApiSensitive(Level.LOW) public static String getSysProp(String key) { try { Class sysProps = XposedHelpers.findClassIfExists("android.os.SystemProperties", null); diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h b/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h index 7a0990cf797..2c76d125a09 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h @@ -60,6 +60,7 @@ namespace art { return instance_; } + // @ApiSensitive(Level.MIDDLE) static void Setup(void *handle, HookFunType hook_func) { HOOK_FUNC(Constructor, "_ZN3art11ClassLinkerC2EPNS_11InternTableE", "_ZN3art11ClassLinkerC2EPNS_11InternTableEb"); // 10.0 diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/gc/heap.h b/edxp-core/src/main/cpp/main/include/art/runtime/gc/heap.h index dde6e854423..fbd78f8b692 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/gc/heap.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/gc/heap.h @@ -37,6 +37,7 @@ namespace art { return instance_; } + // @ApiSensitive(Level.MIDDLE) static void Setup(void *handle, HookFunType hook_func) { HOOK_FUNC(PreZygoteFork, "_ZN3art2gc4Heap13PreZygoteForkEv"); RETRIEVE_FUNC_SYMBOL(WaitForGcToComplete, diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/hidden_api.h b/edxp-core/src/main/cpp/main/include/art/runtime/hidden_api.h index 0e515731471..aa6c2f6e1ae 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/hidden_api.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/hidden_api.h @@ -30,6 +30,7 @@ namespace art { return false; } + // @ApiSensitive(Level.HIGH) static void DisableHiddenApi(void *handle, HookFunType hook_func) { const int api_level = GetAndroidApiLevel(); if (api_level < __ANDROID_API_P__) { diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/jni_env_ext.h b/edxp-core/src/main/cpp/main/include/art/runtime/jni_env_ext.h index 015122dd48d..b04cd16765f 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/jni_env_ext.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/jni_env_ext.h @@ -20,6 +20,7 @@ namespace art { public: JNIEnvExt(void *thiz) : HookedObject(thiz) {} + // @ApiSensitive(Level.MIDDLE) static void Setup(void *handle, HookFunType hook_func) { RETRIEVE_FUNC_SYMBOL(NewLocalRef, "_ZN3art9JNIEnvExt11NewLocalRefEPNS_6mirror6ObjectE"); RETRIEVE_FUNC_SYMBOL(DeleteLocalRef, "_ZN3art9JNIEnvExt14DeleteLocalRefEP8_jobject"); diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/mirror/class.h b/edxp-core/src/main/cpp/main/include/art/runtime/mirror/class.h index 72eb8f2c5ec..55d05dae539 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/mirror/class.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/mirror/class.h @@ -46,6 +46,7 @@ namespace art { public: Class(void *thiz) : HookedObject(thiz) {} + // @ApiSensitive(Level.MIDDLE) static void Setup(void *handle, HookFunType hook_func) { RETRIEVE_FUNC_SYMBOL(GetDescriptor, "_ZN3art6mirror5Class13GetDescriptorEPNSt3__112" "basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE"); diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/oat_file_manager.h b/edxp-core/src/main/cpp/main/include/art/runtime/oat_file_manager.h index 8ac41075cb7..ec3fafb49d5 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/oat_file_manager.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/oat_file_manager.h @@ -11,6 +11,7 @@ namespace art { return; } + // @ApiSensitive(Level.LOW) // http://androidxref.com/9.0.0_r3/xref/art/runtime/oat_file_manager.cc#637 static void DisableOnlyUseSystemOatFiles(void *handle, HookFunType hook_func) { const int api_level = GetAndroidApiLevel(); diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/runtime.h b/edxp-core/src/main/cpp/main/include/art/runtime/runtime.h index 17404d6b557..7451aba22eb 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/runtime.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/runtime.h @@ -36,6 +36,7 @@ namespace art { return instance_; } + // @ApiSensitive(Level.LOW) static void Setup(void *handle, HookFunType hook_func) { HOOK_FUNC(Init, "_ZN3art7Runtime4InitEONS_18RuntimeArgumentMapE"); RETRIEVE_FUNC_SYMBOL(DeoptimizeBootImage, diff --git a/edxp-core/src/main/cpp/main/include/framework/androidfw/ResourceTypes.h b/edxp-core/src/main/cpp/main/include/framework/androidfw/ResourceTypes.h index de0a2907918..dbced16cc4a 100644 --- a/edxp-core/src/main/cpp/main/include/framework/androidfw/ResourceTypes.h +++ b/edxp-core/src/main/cpp/main/include/framework/androidfw/ResourceTypes.h @@ -3,6 +3,7 @@ #include +// @ApiSensitive(Level.MIDDLE) namespace android { typedef int32_t status_t; diff --git a/edxp-core/src/main/cpp/main/include/framework/fd_utils-inl.h b/edxp-core/src/main/cpp/main/include/framework/fd_utils-inl.h index 4bb2bc52aa8..eb68f6d7301 100644 --- a/edxp-core/src/main/cpp/main/include/framework/fd_utils-inl.h +++ b/edxp-core/src/main/cpp/main/include/framework/fd_utils-inl.h @@ -40,7 +40,8 @@ static const char *kPathPrefixWhitelist[] = { static const char *kFdPath = "/proc/self/fd"; -// todo stay up to date +// TODO stay up-to-date +// @ApiSensitive(Level.MIDDLE) // Keeps track of all relevant information (flags, offset etc.) of an // open zygote file descriptor. class FileDescriptorInfo { diff --git a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h b/edxp-core/src/main/cpp/main/include/framework/fd_utils.h index a576337dab3..58a3aa0db6c 100644 --- a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h +++ b/edxp-core/src/main/cpp/main/include/framework/fd_utils.h @@ -4,6 +4,7 @@ #include #include "base/object.h" +// NOT USED namespace android { // Static whitelist of open paths that the zygote is allowed to keep open. diff --git a/edxp-core/src/main/cpp/main/src/config_manager.cpp b/edxp-core/src/main/cpp/main/src/config_manager.cpp index b0a1425c316..9d8830cdea2 100644 --- a/edxp-core/src/main/cpp/main/src/config_manager.cpp +++ b/edxp-core/src/main/cpp/main/src/config_manager.cpp @@ -105,6 +105,7 @@ namespace edxp { } } + // TODO ignore unrelated processes bool ConfigManager::IsAppNeedHook(const std::string &app_data_dir) { // zygote always starts with `uid == 0` and then fork into different user. // so we have to check if we are the correct user or not. diff --git a/edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.cpp b/edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.cpp index 17c20939b62..a426f78a0b1 100644 --- a/edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/jni/edxp_resources_hook.cpp @@ -11,6 +11,7 @@ namespace edxp { return XposedBridge_initXResourcesNative(env, clazz); } + // @ApiSensitive(Level.MIDDLE) static jboolean ResourcesHook_removeFinalFlagNative(JNI_START, jclass target_class) { if (target_class) { jclass class_clazz = JNI_FindClass(env, "java/lang/Class"); diff --git a/edxp-core/src/main/cpp/main/src/main.cpp b/edxp-core/src/main/cpp/main/src/main.cpp index 94b24eb8dac..660d762447c 100644 --- a/edxp-core/src/main/cpp/main/src/main.cpp +++ b/edxp-core/src/main/cpp/main/src/main.cpp @@ -23,6 +23,7 @@ namespace edxp { + // TODO exclude unrelated processes EXPORT void onModuleLoaded() { LOG(INFO) << "onModuleLoaded: welcome to EdXposed!"; InstallInlineHooks(); diff --git a/edxp-core/src/main/cpp/main/src/native_hook.cpp b/edxp-core/src/main/cpp/main/src/native_hook.cpp index 41e77190393..b80eece5b3b 100644 --- a/edxp-core/src/main/cpp/main/src/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/native_hook.cpp @@ -80,7 +80,9 @@ namespace edxp { InstallFwkHooks(fwk_handle.Get()); } + // @ApiSensitive(Level.MIDDLE) bool InstallLinkerHooks(const char *linker_path) { + // TODO flags void *handle = dlopen(kLibSandHookNativePath.c_str(), RTLD_NOW); if (!handle) { diff --git a/edxp-core/src/main/cpp/main/src/resource_hook.cpp b/edxp-core/src/main/cpp/main/src/resource_hook.cpp index 1a5563d267d..41d2fb8f628 100644 --- a/edxp-core/src/main/cpp/main/src/resource_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/resource_hook.cpp @@ -15,6 +15,7 @@ #include "resource_hook.h" #include "dl_util.h" +// @ApiSensitive(Level.HIGH) namespace edxp { static constexpr const char *kXResourcesClassName = "android/content/res/XResources"; diff --git a/edxp-core/src/main/cpp/main/src/riru_hook.h b/edxp-core/src/main/cpp/main/src/riru_hook.h index 0f551bc6021..5fd8efe1566 100644 --- a/edxp-core/src/main/cpp/main/src/riru_hook.h +++ b/edxp-core/src/main/cpp/main/src/riru_hook.h @@ -20,6 +20,7 @@ namespace edxp { + // @ApiSensitive(Level.HIGH) static constexpr const char *kPropKeyCompilerFilter = "dalvik.vm.dex2oat-filter"; static constexpr const char *kPropKeyCompilerFlags = "dalvik.vm.dex2oat-flags"; static constexpr const char *kPropKeyUseJitProfiles = "dalvik.vm.usejitprofiles"; diff --git a/edxp-sandhook/build.gradle b/edxp-sandhook/build.gradle index 93cf624102a..f1e426488ac 100644 --- a/edxp-sandhook/build.gradle +++ b/edxp-sandhook/build.gradle @@ -27,7 +27,6 @@ android { dependencies { compileOnly files("${hiddenApiStubJarFilePath}") implementation project(':edxp-common') - implementation project(':xposed-bridge') implementation 'com.swift.sandhook:hooklib:4.2.1' compileOnly project(':dexmaker') } diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/HandleBindAppHooker.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/HandleBindAppHooker.java index 60cb6fd2299..496b2bc2d29 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/HandleBindAppHooker.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/HandleBindAppHooker.java @@ -15,7 +15,10 @@ import java.lang.reflect.Method; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) @HookClass(ActivityThread.class) public class HandleBindAppHooker implements KeepMembers { diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/LoadedApkConstructorHooker.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/LoadedApkConstructorHooker.java index 29c6d0e1dce..efa05afbb7f 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/LoadedApkConstructorHooker.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/LoadedApkConstructorHooker.java @@ -17,7 +17,10 @@ import java.lang.reflect.Method; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) @HookClass(LoadedApk.class) public class LoadedApkConstructorHooker implements KeepMembers { public static String className = "android.app.LoadedApk"; diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/OnePlusWorkAroundHooker.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/OnePlusWorkAroundHooker.java index 48b0ba61dda..92089ad6f89 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/OnePlusWorkAroundHooker.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/OnePlusWorkAroundHooker.java @@ -13,7 +13,11 @@ import dalvik.system.BaseDexClassLoader; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +// TODO check HOS / OOS ver.11 when available +@ApiSensitive(Level.MIDDLE) @HookClass(BaseDexClassLoader.class) public class OnePlusWorkAroundHooker implements KeepMembers { diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/StartBootstrapServicesHooker11.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/StartBootstrapServicesHooker11.java index da189c4e0f4..eb4bcb88681 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/StartBootstrapServicesHooker11.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/StartBootstrapServicesHooker11.java @@ -13,7 +13,10 @@ import java.lang.reflect.Method; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) @HookReflectClass("com.android.server.SystemServer") public class StartBootstrapServicesHooker11 implements KeepMembers { public static String className = "com.android.server.SystemServer"; diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/SystemMainHooker.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/SystemMainHooker.java index 2280ca53dc7..1c0d5d9579c 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/SystemMainHooker.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/hooker/SystemMainHooker.java @@ -12,8 +12,11 @@ import java.lang.reflect.Method; import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; +@ApiSensitive(Level.LOW) // system_server initialization // ed: only support sdk >= 21 for now @HookClass(ActivityThread.class) diff --git a/edxp-whale/build.gradle b/edxp-whale/build.gradle index 4c9d5d4af9e..76a1d7fb289 100644 --- a/edxp-whale/build.gradle +++ b/edxp-whale/build.gradle @@ -27,7 +27,6 @@ android { dependencies { compileOnly files("${hiddenApiStubJarFilePath}") implementation project(':edxp-common') - implementation project(':xposed-bridge') compileOnly project(':dexmaker') } diff --git a/edxp-yahfa/build.gradle b/edxp-yahfa/build.gradle index 7e7cf27d7e9..f142309c10b 100644 --- a/edxp-yahfa/build.gradle +++ b/edxp-yahfa/build.gradle @@ -27,7 +27,6 @@ android { dependencies { compileOnly files("${hiddenApiStubJarFilePath}") implementation project(':edxp-common') - implementation project(':xposed-bridge') compileOnly project(':dexmaker') } diff --git a/xposed-bridge/src/main/java/de/robv/android/xposed/XposedBridge.java b/xposed-bridge/src/main/java/de/robv/android/xposed/XposedBridge.java index dd1a718cf3f..79dc3f7b5db 100644 --- a/xposed-bridge/src/main/java/de/robv/android/xposed/XposedBridge.java +++ b/xposed-bridge/src/main/java/de/robv/android/xposed/XposedBridge.java @@ -21,6 +21,8 @@ import dalvik.system.InMemoryDexClassLoader; import de.robv.android.xposed.XC_MethodHook.MethodHookParam; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; import de.robv.android.xposed.callbacks.XC_InitPackageResources; import de.robv.android.xposed.callbacks.XC_InitZygote; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -92,6 +94,7 @@ public static void main(String[] args) { public static volatile ClassLoader dummyClassLoader = null; + @ApiSensitive(Level.MIDDLE) public static void initXResources() { if (dummyClassLoader != null) { return; diff --git a/xposed-bridge/src/main/java/de/robv/android/xposed/XposedInit.java b/xposed-bridge/src/main/java/de/robv/android/xposed/XposedInit.java index c763fb2e908..51169f4d0b6 100644 --- a/xposed-bridge/src/main/java/de/robv/android/xposed/XposedInit.java +++ b/xposed-bridge/src/main/java/de/robv/android/xposed/XposedInit.java @@ -34,6 +34,8 @@ import dalvik.system.DexFile; import dalvik.system.PathClassLoader; +import de.robv.android.xposed.annotation.ApiSensitive; +import de.robv.android.xposed.annotation.Level; import de.robv.android.xposed.callbacks.XC_InitPackageResources; import de.robv.android.xposed.callbacks.XC_InitZygote; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -91,6 +93,7 @@ public static void initForZygote(boolean isSystem) throws Throwable { hookResources(); } + @ApiSensitive(Level.MIDDLE) private static void hookResources() throws Throwable { if (!EdXpConfigGlobal.getConfig().isResourcesHookEnabled() || disableResources) { return; @@ -265,6 +268,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { XResources.init(latestResKey); } + @ApiSensitive(Level.MIDDLE) private static XResources cloneToXResources(XC_MethodHook.MethodHookParam param, String resDir) { Object result = param.getResult(); if (result == null || result instanceof XResources || diff --git a/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/ApiSensitive.java b/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/ApiSensitive.java new file mode 100644 index 00000000000..75466f60295 --- /dev/null +++ b/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/ApiSensitive.java @@ -0,0 +1,17 @@ +package de.robv.android.xposed.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation that indicates a element is sensitive to Android API level. + *

+ * Annotated elements' compatibility should be checked when adapting to new Android versions. + */ +@Retention(RetentionPolicy.SOURCE) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) +public @interface ApiSensitive { + Level value() default Level.HIGH; +} diff --git a/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/Level.java b/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/Level.java new file mode 100644 index 00000000000..54d5869ef42 --- /dev/null +++ b/xposed-bridge/src/main/java/de/robv/android/xposed/annotation/Level.java @@ -0,0 +1,9 @@ +package de.robv.android.xposed.annotation; + +public enum Level { + LOW, MIDDLE, HIGH; + + private Level() { + + } +} \ No newline at end of file