Skip to content

Commit

Permalink
Add an annotation to remind compatibility checking
Browse files Browse the repository at this point in the history
  • Loading branch information
solohsu committed Aug 2, 2020
1 parent b1838bf commit e12c40b
Show file tree
Hide file tree
Showing 50 changed files with 123 additions and 19 deletions.
2 changes: 1 addition & 1 deletion edxp-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public Void run() {
});
}

// TODO do this earlier?
private static boolean isBlackListedProcess(int uid) {
return ProcessHelper.isIsolated(uid)
|| ProcessHelper.isRELROUpdater(uid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -143,6 +146,7 @@ public void startSystemServerHook() {
}
}

@ApiSensitive(Level.LOW)
public void startWorkAroundHook() {
ClassLoader classLoader = BaseRouter.class.getClassLoader();
if (useXposedApi) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/include/art/runtime/gc/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/include/art/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cstdint>

// @ApiSensitive(Level.MIDDLE)
namespace android {

typedef int32_t status_t;
Expand Down
3 changes: 2 additions & 1 deletion edxp-core/src/main/cpp/main/include/framework/fd_utils-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/include/framework/fd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <android-base/strings.h>
#include "base/object.h"

// NOT USED
namespace android {

// Static whitelist of open paths that the zygote is allowed to keep open.
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/src/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace edxp {

// TODO exclude unrelated processes
EXPORT void onModuleLoaded() {
LOG(INFO) << "onModuleLoaded: welcome to EdXposed!";
InstallInlineHooks();
Expand Down
2 changes: 2 additions & 0 deletions edxp-core/src/main/cpp/main/src/native_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/src/resource_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/src/riru_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit e12c40b

Please sign in to comment.