package com.xfunforx.zfbar;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.View;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class ARzfb implements IXposedHookLoadPackage {
static {
XposedBridge.log("===============zfb module========");
}
public static final String apmClassName = "android.app.ApplicationPackageManager";
public static final String apmClassMethodName1 = "getInstalledApplications";
public static final String apmClassMethodName2 = "getInstalledPackages";
static Object af;
Map hooed = new HashMap();
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if (loadPackageParam.packageName.equals("com.eg.android.AlipayGphone")) {
XposedBridge.log("===============zfb found========");
XposedHelpers.findAndHookMethod("com.alipay.mobile.base.security.CheckInject", loadPackageParam.classLoader, "a", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("****** w假装没有root");
param.setResult(false);
}
});
XposedHelpers.findAndHookMethod("java.lang.ClassLoader", loadPackageParam.classLoader, "loadClass", String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
final Class re;
if (param.getResult() != null) {
re = (Class) param.getResult();
String cn = re.getName();
// 关键字判断
if (!cn.contains("arenvelope")) {
return;
}
// 下面逻辑防止重复hook,加快速度
if (hooed.containsKey(cn)){
return;
}else{
hooed.put(cn,cn);
}
if (cn.equals("com.alipay.android.phone.arenvelope.ui.find.ArFindActivity")){
XposedHelpers.findAndHookMethod(re, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// 这里保存 af,到时打开红包需要用到
af = param.thisObject;
XposedBridge.log("save the af=="+af.getClass().getName());
}
});
}
if (cn.equals("com.alipay.android.phone.arenvelope.ui.find.ah")){
// 这个是投诉红包的那个菜单栏
XposedHelpers.findAndHookMethod(re, "onClick", View.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
Object lc = XposedHelpers.getObjectField(af,"f");
// 可以把下面这个id换成你自己找的图片id
// 调用下载的方法直接开启红包
XposedHelpers.callMethod(af, "a", lc, "m0hkS3iXQNKXet4dGUVkNAAAACMAAQED");
return null;
}
});
}
}
}
});
final Class<?> apmClass;
try {
apmClass = XposedHelpers.findClass(apmClassName, loadPackageParam.classLoader);
} catch (XposedHelpers.ClassNotFoundError e) {
return;
}
try {
// 隐藏xposed
XposedHelpers.findAndHookMethod(apmClass, apmClassMethodName1, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("****************InstalledApplicationsHook");
List installedApplications = (List) param.getResult();
ArrayList<ApplicationInfo> sortedOutApplications = new ArrayList<>();
for (Object application : installedApplications) {
ApplicationInfo applicationInfo = (ApplicationInfo) application;
if (!applicationInfo.packageName.contains("de.robv.android.xposed.installer")) {
sortedOutApplications.add(applicationInfo);
}
}
param.setResult(sortedOutApplications);
}
});
} catch (NoSuchMethodError error) {
;
}
try {
// 隐藏xposed
XposedHelpers.findAndHookMethod(apmClass, apmClassMethodName2, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("**************InstalledPackagesHook");
List installedPackages = (List) param.getResult();
ArrayList<PackageInfo> sortedOutPackages = new ArrayList<>();
for (Object installedPackage : installedPackages) {
PackageInfo packageInfo = (PackageInfo) installedPackage;
if (!packageInfo.packageName.contains("de.robv.android.xposed.installer")) {
sortedOutPackages.add(packageInfo);
}
}
param.setResult(sortedOutPackages);
}
});
} catch (NoSuchMethodError error) {
}
}
}
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.