Skip to content

Instantly share code, notes, and snippets.

@LeadroyaL LeadroyaL/Entry.java
Created May 10, 2020

Embed
What would you like to do?
使用xposed跳过小米USB安装应用确认

使用xposed跳过小米USB安装应用确认

QQ20200510-194855@2x

package com.leadroyal.miuiusb;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class Entry implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals("com.miui.securitycenter")) {
XposedBridge.log("Patch miui usb alert START");
Class adbInstallActivity = XposedHelpers.findClass("com.miui.permcenter.install.AdbInstallActivity", lpparam.classLoader);
Method isEnabledMethod = null;
for (Field f : adbInstallActivity.getDeclaredFields()) {
Class<?> fieldClz = f.getType();
try {
if (fieldClz != null && fieldClz.getDeclaredMethod("isEnabled") != null) {
isEnabledMethod = fieldClz.getDeclaredMethod("isEnabled");
break;
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
if (isEnabledMethod == null) {
XposedBridge.log("cannot find isEnabled");
} else {
XposedBridge.log("find isEnabled and hook it");
XposedBridge.hookMethod(isEnabledMethod, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
param.setResult(false);
}
});
}
XposedBridge.log("Patch miui usb alert END");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.