android usb port switch


Copyright statement: This article is an original article by CSDN blogger "Communication Man", and follows the CC 4.0 BY-SA copyright agreement. For reprinting, please attach the original source link and this statement.
Original link: https://blog.csdn.net/qq_28534581/article/details/80308518

 

Preface: There is a Korean client who needs to call the rndis port for authentication. This function can be viewed on Samsung mobile phones, but the general android device does not enable this function, it is estimated that Samsung added it.

Not much to say, the usb port function has been written long ago, but the driver needs to analyze whether it supports it and then turn on the corresponding switch. The implementation is in the file init.qcom.usb.rc, now intercept the functions we need:

on property:sys.usb.config=rndis,serial_smd,diag,adb
    stop adbd
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 05C6
    write /sys/class/android_usb/android0/idProduct 90B6
    write /sys/class/android_usb/android0/f_diag/clients diag
    write /sys/class/android_usb/android0/f_serial/transports smd
    write /sys/class/android_usb/android0/functions rndis,serial,diag,adb
    write /sys/class/android_usb/android0/enable 1
    start adbd
    setprop sys.usb.state rndis,adb
1
2
3
4
5
6
7
8
9
10
11
It can be seen that as long as the attribute sys.usb.config is set, each of the following instructions will be executed again. Are you familiar with 05c6/90B6? We can connect the computer to see the corresponding port through the device manager. 
There is also a small hole here, that is, after the setting is completed, the system will check whether sys.usb.state and sys.usb.config are equal, and then set it up, otherwise it will be restored. 
So what we actually set is not the attribute value rndis, serial_smd, diag, adb, but rndis, adb

on property:sys.usb.config=rndis,adb
    setprop sys.usb.config rndis,${persist.sys.usb.config.extra},adb
1
2
Here you need to add another property persist.sys.usb.config .extra, add the corresponding value inside, you can correspond to the top value, namely persist.sys.usb.config.extra=serial_smd,diag
———————————————
Copyright Disclaimer: This article is an original article by CSDN blogger "Communication Man", and follows the CC 4.0 BY-SA copyright agreement. For reprinting, please attach the original source link and this statement.
Original link: https://blog.csdn.net/qq_28534581/article/details/80308518

Guess you like

Origin blog.csdn.net/grf123/article/details/102967492