美文网首页
android adb调试之wifi和adb

android adb调试之wifi和adb

作者: 锄禾豆 | 来源:发表于2022-02-09 08:17 被阅读0次

参考学习:

https://www.jianshu.com/p/dc6898380e38
https://www.jianshu.com/p/825e528a8311
https://blog.csdn.net/tumuzhuanjia/article/details/7691869

Wifi:

系统端:

在*.rc中导入:

# for Internet adb 
on property:persist.internet.adb.enable=1
    setprop service.adb.tcp.port 5555
    restart adbd

# for Internet adb 
on property:persist.internet.adb.enable=0
    setprop service.adb.tcp.port 0
    restart adbd

客户端:

代码
SystemProperties.set("persist.internet.adb.enable", "1");//"0"

adb
adb shell setprop persist.internet.adb.enable  1/0

adb:

客户端:

Settings.Global.putInt(context.getApplicationContext().getContentResolver(), Settings.Global.ADB_ENABLED, value);

系统端:

com.android.serer.usb.UsbDeviceManager

mContentResolver.registerContentObserver(
    Settings.Global.getUriFor(Settings.Global.ADB_ENABLED),
        false, new AdbSettingsObserver());

private static final String USB_PERSISTENT_CONFIG_PROPERTY = "persist.sys.usb.config";
private void setAdbEnabled(boolean enable) {
    ···
    SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunction);
    ···
}

也就是说,最后仍是执行的是persist.sys.usb.config操作
例如,setprop persist.sys.usb.config adb

回到init.usb.rc
on property:sys.usb.config=adb && property:sys.usb.configfs=0
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct 4EE7
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/enable 1
    start adbd
    setprop sys.usb.state ${sys.usb.config}

案例

adb shell setprop persist.internet.adb.enable
adb connect ip

相关文章

网友评论

      本文标题:android adb调试之wifi和adb

      本文链接:https://www.haomeiwen.com/subject/asgqkrtx.html