Skip to content

Instantly share code, notes, and snippets.

@LeadroyaL

LeadroyaL/Entry.java

Last active Sep 2, 2020
Embed
What would you like to do?
使用 xposed 自动开启 oppo usb 调试

使用 xposed 自动开启 oppo usb 调试

IMG_20200901_153313

package com.leadroyal.oppousb;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
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 Entry implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
ClassLoader classLoader = lpparam.classLoader;
if (lpparam.packageName.equals("com.android.systemui")) {
XposedBridge.log("Patch oppo usb dialog START");
XposedHelpers.findAndHookMethod("com.coloros.systemui.notification.usb.UsbService", classLoader, "onUsbConnected", Context.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
Object thiz = param.thisObject;
thiz.getClass().getMethod("updateAdbNotification", Context.class).invoke(thiz, (Context) param.args[0]);
thiz.getClass().getField("sNeedShowUsbDialog").set(null, false);
thiz.getClass().getMethod("updateUsbNotification", Context.class, int.class).invoke(thiz, (Context) param.args[0], 1);
return null;
}
});
XposedBridge.log("Patch oppo usb dialog 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.