1.检测安装包名
private static int l(Context context) {
int i = 0;
PackageManager packageManager = context.getPackageManager();
try {
packageManager.getInstallerPackageName("de.robv.android.xposed.installer");
i = 1;
} catch (Exception e2) {
}
try {
packageManager.getInstallerPackageName("com.saurik.substrate");
return i | 2;
} catch (Exception e3) {
return i;
}
}
2.检测注入框架的类名和函数名称
private static int v() {
StackTraceElement[] stackTrace;
int i = 0;
try {
throw new Exception("detect hook");
} catch (Exception e2) {
int i2 = 0;
for (StackTraceElement stackTraceElement : e2.getStackTrace()) {
if (stackTraceElement.getClassName().equals("de.robv.android.xposed.XposedBridge") && stackTraceElement.getMethodName().equals("main")) {
i2 |= 4;
}
if (stackTraceElement.getClassName().equals("de.robv.android.xposed.XposedBridge") && stackTraceElement.getMethodName().equals("handleHookedMethod")) {
i2 |= 8;
}
if (stackTraceElement.getClassName().equals("com.saurik.substrate.MS$2") && stackTraceElement.getMethodName().equals("invoked")) {
i2 |= 16;
}
if (stackTraceElement.getClassName().equals("com.android.internal.os.ZygoteInit")) {
i++;
if (i == 2) {
i2 |= 32;
}
}
}
return i2;
}
}