-
-
Save hhhaiai/194c85ffe768053a26d04f0dda20707d to your computer and use it in GitHub Desktop.
使用xposed跳过小米USB安装应用确认
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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