Skip to content

Instantly share code, notes, and snippets.

@hhhaiai
Forked from LeadroyaL/Entry.java
Created March 4, 2021 08:39
Show Gist options
  • Save hhhaiai/194c85ffe768053a26d04f0dda20707d to your computer and use it in GitHub Desktop.
Save hhhaiai/194c85ffe768053a26d04f0dda20707d to your computer and use it in GitHub Desktop.
使用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