#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