1on boot
2    mount configfs none /config
3    mkdir /config/usb_gadget/g1 0770 shell shell
4    mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell
5    write /config/usb_gadget/g1/bcdUSB 0x0200
6    write /config/usb_gadget/g1/idVendor 0x18d1
7    write /config/usb_gadget/g1/bcdDevice 0x0223
8    write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
9    write /config/usb_gadget/g1/strings/0x409/manufacturer SEI
10    write /config/usb_gadget/g1/strings/0x409/product ${ro.hardware}
11    mkdir /config/usb_gadget/g1/functions/ffs.adb
12    mkdir /config/usb_gadget/g1/functions/ffs.mtp
13    mkdir /config/usb_gadget/g1/functions/ffs.ptp
14    mkdir /config/usb_gadget/g1/functions/gsi.rndis
15    mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell
16    mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
17    write /config/usb_gadget/g1/configs/b.1/MaxPower 500
18    mkdir /dev/usb-ffs 0775 shell shell
19    mkdir /dev/usb-ffs/adb 0770 shell shell
20    mkdir /dev/usb-ffs/mtp 0770 mtp mtp
21    mkdir /dev/usb-ffs/ptp 0770 mtp mtp
22    mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
23    mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
24    mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
25    setprop sys.usb.mtp.device_type 3
26    setprop sys.usb.configfs 1
27    setprop sys.usb.controller "ff400000.usb"
28    symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
29    write /config/usb_gadget/g1/functions/gsi.rndis/rndis_class_id 1
30
31
32on property:sys.usb.config=none && property:sys.usb.configfs=1
33    setprop sys.usb.ffs.ready 0
34
35on property:init.svc.adbd=stopped
36    setprop sys.usb.ffs.ready 0
37
38on property:sys.usb.config=mtp && property:sys.usb.configfs=1
39    write /config/usb_gadget/g1/idProduct 0x4e41
40
41on property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1
42    write /config/usb_gadget/g1/idProduct 0x4e12
43
44on property:sys.usb.config=adb && property:sys.usb.configfs=1
45    write /config/usb_gadget/g1/idProduct 0x4e40
46    write /sys/class/usb_role/ffe09000.usb-role-switch/role device
47