Skip to content

Instantly share code, notes, and snippets.

@LeadroyaL
Last active September 2, 2020 06:20
Show Gist options
  • Save LeadroyaL/e271ca18f213f058b8e310654cae310d to your computer and use it in GitHub Desktop.
Save LeadroyaL/e271ca18f213f058b8e310654cae310d to your computer and use it in GitHub Desktop.
使用 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