1on early-boot
2    mkdir /config/usb_gadget/g1
3    mkdir /config/usb_gadget/g1/strings/0x409
4    mkdir /config/usb_gadget/g1/configs/b.1
5    write /config/usb_gadget/g1/idVendor 0x18d1
6    write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
7    write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
8    write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
9    write /config/usb_gadget/g1/configs/b.1/MaxPower 0x384
10    write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
11    write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
12
13    # ffs function
14    mkdir /config/usb_gadget/g1/functions/ffs.adb 0770 shell shell
15    mkdir /config/usb_gadget/g1/functions/ffs.mtp
16    mkdir /config/usb_gadget/g1/functions/ffs.ptp
17    mkdir /dev/usb-ffs 0775 shell shell
18    mkdir /dev/usb-ffs/adb 0770 shell shell
19    mkdir /dev/usb-ffs/mtp 0770 mtp mtp
20    mkdir /dev/usb-ffs/ptp 0770 mtp mtp
21    mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1
22    mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
23    mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
24    setprop sys.usb.mtp.device_type 3
25    setprop sys.usb.mtp.batchcancel true
26    symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
27
28    # mtp function
29    mkdir /config/usb_gadget/g1/functions/mtp.gs0
30
31    # ptp function
32    mkdir /config/usb_gadget/g1/functions/ptp.gs1
33
34    # accessory function
35    mkdir /config/usb_gadget/g1/functions/accessory.gs2
36
37    # audio_source function
38    mkdir /config/usb_gadget/g1/functions/audio_source.gs3
39
40    # rndis function
41    mkdir /config/usb_gadget/g1/functions/rndis.gs4
42    # Modify class/subclass/protocol for rndis.gs4
43    # Remote NDIS: Class: Wireless Controller (0xe0), Subclass: 0x1, Protocol: 0x3
44    write /config/usb_gadget/g1/functions/rndis.gs4/class e0
45    write /config/usb_gadget/g1/functions/rndis.gs4/subclass 01
46    write /config/usb_gadget/g1/functions/rndis.gs4/protocol 03
47    write /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.ncm/compatible_id RNDIS
48    write /config/usb_gadget/g1/functions/rndis.gs4/ifname rndis%d
49    setprop vendor.usb.rndis.config rndis.gs4
50
51    # midi function
52    mkdir /config/usb_gadget/g1/functions/midi.gs5
53
54    # acm function
55    mkdir /config/usb_gadget/g1/functions/acm.gs6
56
57    # dm function
58    mkdir /config/usb_gadget/g1/functions/dm.gs7
59
60    # uts function
61    mkdir /config/usb_gadget/g1/functions/uts.gs8
62
63    # ncm function
64    mkdir /config/usb_gadget/g1/functions/ncm.gs9
65    write /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/compatible_id WINNCM
66    write /config/usb_gadget/g1/functions/ncm.gs9/ifname ncm%d
67
68    # etr_miu function
69    mkdir /config/usb_gadget/g1/functions/etr_miu.gs11
70
71    # acm function for uwb
72    mkdir /config/usb_gadget/g1/functions/acm.uwb0
73
74    # uvc function
75    mkdir /config/usb_gadget/g1/functions/uvc.0
76    write /config/usb_gadget/g1/functions/uvc.0/function_name "Android Webcam"
77    write /config/usb_gadget/g1/functions/uvc.0/streaming_maxpacket 3072
78    # write /config/usb_gadget/g1/functions/uvc.0/streaming_maxburst 5
79    # write /config/usb_gadget/g1/functions/uvc.0/streaming_interval 2
80    # setup control params
81    mkdir /config/usb_gadget/g1/functions/uvc.0/control/header/h
82    symlink /config/usb_gadget/g1/functions/uvc.0/control/header/h /config/usb_gadget/g1/functions/uvc.0/control/class/fs/h
83    symlink /config/usb_gadget/g1/functions/uvc.0/control/header/h /config/usb_gadget/g1/functions/uvc.0/control/class/ss/h
84    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m
85    # advertise 360p resolution for webcam encoded as mjpeg
86    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p
87    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wHeight 360
88    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wWidth 640
89    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize 460800
90    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwDefaultFrameInterval 333333
91    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwFrameInterval "166666
92333333
93416666
94666666"
95    # advertise 480p resolution for webcam encoded as mjpeg
96    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p
97    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wHeight 480
98    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wWidth 640
99    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMaxVideoFrameBufferSize 614400
100    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwDefaultFrameInterval 333333
101    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwFrameInterval "166666
102333333
103416666
104666666"
105    # advertise 720p resolution for webcam encoded as mjpeg
106    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p
107    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wHeight 720
108    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wWidth 1280
109    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize 1843200
110    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwDefaultFrameInterval 333333
111    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwFrameInterval "166666
112333333
113416666
114666666"
115    # advertise 1080p resolution for webcam encoded as mjpeg
116    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p
117    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wHeight 1080
118    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wWidth 1920
119    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize 4147200
120    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwDefaultFrameInterval 333333
121    write /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwFrameInterval "166666
122333333
123416666
124666666"
125    # TODO: Add uncompressed streams
126    # setup streaming params
127    mkdir /config/usb_gadget/g1/functions/uvc.0/streaming/header/h
128    symlink /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/m
129    symlink /config/usb_gadget/g1/functions/uvc.0/streaming/header/h /config/usb_gadget/g1/functions/uvc.0/streaming/class/fs/h
130    symlink /config/usb_gadget/g1/functions/uvc.0/streaming/header/h /config/usb_gadget/g1/functions/uvc.0/streaming/class/hs/h
131    symlink /config/usb_gadget/g1/functions/uvc.0/streaming/header/h /config/usb_gadget/g1/functions/uvc.0/streaming/class/ss/h
132    # remove write permissions for 'others'
133    chmod 664 /config/usb_gadget/g1/functions/uvc.0/control/header/h/bcdUVC
134    chmod 664 /config/usb_gadget/g1/functions/uvc.0/control/header/h/dwClockFrequency
135    chmod 664 /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/bSourceID
136    chmod 664 /config/usb_gadget/g1/functions/uvc.0/function_name
137    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming_interval
138    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming_maxburst
139    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming_maxpacket
140    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/bmCapabilities
141    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwDefaultFrameInterval
142    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwFrameInterval
143    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMaxBitRate
144    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize
145    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMinBitRate
146    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wHeight
147    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wWidth
148    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/bmCapabilities
149    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwDefaultFrameInterval
150    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwFrameInterval
151    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMaxBitRate
152    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize
153    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMinBitRate
154    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wHeight
155    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wWidth
156    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/bmCapabilities
157    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwDefaultFrameInterval
158    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwFrameInterval
159    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMaxBitRate
160    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMaxVideoFrameBufferSize
161    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMinBitRate
162    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wHeight
163    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wWidth
164    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/bmCapabilities
165    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwDefaultFrameInterval
166    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwFrameInterval
167    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMaxBitRate
168    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize
169    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMinBitRate
170    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wHeight
171    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wWidth
172    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bDefaultFrameIndex
173    chmod 664 /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmaControls
174
175    # chown file/folder permission
176    chown system system /config/usb_gadget/
177    chown system system /config/usb_gadget/g1
178    chown system system /config/usb_gadget/g1/UDC
179    chown system system /config/usb_gadget/g1/bDeviceClass
180    chown system system /config/usb_gadget/g1/bDeviceProtocol
181    chown system system /config/usb_gadget/g1/bDeviceSubClass
182    chown system system /config/usb_gadget/g1/bMaxPacketSize0
183    chown system system /config/usb_gadget/g1/bcdDevice
184    chown system system /config/usb_gadget/g1/bcdUSB
185    chown system system /config/usb_gadget/g1/configs
186    chown system system /config/usb_gadget/g1/configs/b.1
187    chown system system /config/usb_gadget/g1/configs/b.1/MaxPower
188    chown system system /config/usb_gadget/g1/configs/b.1/bmAttributes
189    chown system system /config/usb_gadget/g1/configs/b.1/strings
190    chown system system /config/usb_gadget/g1/functions
191    chown system system /config/usb_gadget/g1/functions/accessory.gs2
192    chown system system /config/usb_gadget/g1/functions/acm.gs6
193    chown system system /config/usb_gadget/g1/functions/acm.gs6/port_num
194    chown system system /config/usb_gadget/g1/functions/acm.uwb0
195    chown system system /config/usb_gadget/g1/functions/acm.uwb0/port_num
196    chown system system /config/usb_gadget/g1/functions/audio_source.gs3
197    chown system system /config/usb_gadget/g1/functions/dm.gs7
198    chown system system /config/usb_gadget/g1/functions/ffs.adb
199    chown system system /config/usb_gadget/g1/functions/ffs.mtp
200    chown system system /config/usb_gadget/g1/functions/ffs.ptp
201    chown system system /config/usb_gadget/g1/functions/midi.gs5
202    chown system system /config/usb_gadget/g1/functions/midi.gs5/buflen
203    chown system system /config/usb_gadget/g1/functions/midi.gs5/id
204    chown system system /config/usb_gadget/g1/functions/midi.gs5/in_ports
205    chown system system /config/usb_gadget/g1/functions/midi.gs5/index
206    chown system system /config/usb_gadget/g1/functions/midi.gs5/out_ports
207    chown system system /config/usb_gadget/g1/functions/midi.gs5/qlen
208    chown system system /config/usb_gadget/g1/functions/mtp.gs0
209    chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc
210    chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP
211    chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/compatible_id
212    chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/sub_compatible_id
213    chown system system /config/usb_gadget/g1/functions/ncm.gs9
214    chown system system /config/usb_gadget/g1/functions/ncm.gs9/dev_addr
215    chown system system /config/usb_gadget/g1/functions/ncm.gs9/host_addr
216    chown system system /config/usb_gadget/g1/functions/ncm.gs9/ifname
217    chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc
218    chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm
219    chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/compatible_id
220    chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/sub_compatible_id
221    chown system system /config/usb_gadget/g1/functions/ncm.gs9/qmult
222    chown system system /config/usb_gadget/g1/functions/ptp.gs1
223    chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc
224    chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP
225    chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/compatible_id
226    chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/sub_compatible_id
227    chown system system /config/usb_gadget/g1/functions/rndis.gs4
228    chown system system /config/usb_gadget/g1/functions/rndis.gs4/class
229    chown system system /config/usb_gadget/g1/functions/rndis.gs4/dev_addr
230    chown system system /config/usb_gadget/g1/functions/rndis.gs4/host_addr
231    chown system system /config/usb_gadget/g1/functions/rndis.gs4/ifname
232    chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc
233    chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis
234    chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/compatible_id
235    chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/sub_compatible_id
236    chown system system /config/usb_gadget/g1/functions/rndis.gs4/protocol
237    chown system system /config/usb_gadget/g1/functions/rndis.gs4/qmult
238    chown system system /config/usb_gadget/g1/functions/rndis.gs4/subclass
239    chown system system /config/usb_gadget/g1/functions/uvc.0
240    chown system system /config/usb_gadget/g1/functions/uvc.0/control
241    chown system system /config/usb_gadget/g1/functions/uvc.0/control/bInterfaceNumber
242    chown system system /config/usb_gadget/g1/functions/uvc.0/control/class
243    chown system system /config/usb_gadget/g1/functions/uvc.0/control/class/fs
244    chown system system /config/usb_gadget/g1/functions/uvc.0/control/class/fs/h
245    chown system system /config/usb_gadget/g1/functions/uvc.0/control/class/ss
246    chown system system /config/usb_gadget/g1/functions/uvc.0/control/class/ss/h
247    chown system system /config/usb_gadget/g1/functions/uvc.0/control/header
248    chown system system /config/usb_gadget/g1/functions/uvc.0/control/header/h
249    chown system system /config/usb_gadget/g1/functions/uvc.0/control/header/h/bcdUVC
250    chown system system /config/usb_gadget/g1/functions/uvc.0/control/header/h/dwClockFrequency
251    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing
252    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default
253    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default/bmControls
254    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default/bSourceID
255    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default/bUnitID
256    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default/iProcessing
257    chown system system /config/usb_gadget/g1/functions/uvc.0/control/processing/default/wMaxMultiplier
258    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal
259    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera
260    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default
261    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/bAssocTerminal
262    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/bmControls
263    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/bTerminalID
264    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/iTerminal
265    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/wObjectiveFocalLengthMax
266    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/wObjectiveFocalLengthMin
267    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/wOcularFocalLength
268    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/camera/default/wTerminalType
269    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output
270    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default
271    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/bAssocTerminal
272    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/bSourceID
273    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/bTerminalID
274    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/iTerminal
275    chown system system /config/usb_gadget/g1/functions/uvc.0/control/terminal/output/default/wTerminalType
276    chown system system /config/usb_gadget/g1/functions/uvc.0/function_name
277    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming
278    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming_interval
279    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming_maxburst
280    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming_maxpacket
281    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/bInterfaceNumber
282    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class
283    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/fs
284    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/fs/h
285    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/hs
286    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/hs/h
287    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/ss
288    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/class/ss/h
289    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/color_matching
290    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/color_matching/default
291    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/color_matching/default/bColorPrimaries
292    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/color_matching/default/bMatrixCoefficients
293    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/color_matching/default/bTransferCharacteristics
294    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header
295    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h
296    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/bmInfo
297    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/bStillCaptureMethod
298    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/bTerminalLink
299    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/bTriggerSupport
300    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/bTriggerUsage
301    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/header/h/m
302    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg
303    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m
304    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p
305    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/bFrameIndex
306    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/bmCapabilities
307    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwDefaultFrameInterval
308    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwFrameInterval
309    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMaxBitRate
310    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize
311    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/dwMinBitRate
312    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wHeight
313    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/1080p/wWidth
314    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p
315    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/bFrameIndex
316    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/bmCapabilities
317    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwDefaultFrameInterval
318    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwFrameInterval
319    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMaxBitRate
320    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize
321    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/dwMinBitRate
322    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wHeight
323    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/360p/wWidth
324    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p
325    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/bFrameIndex
326    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/bmCapabilities
327    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwDefaultFrameInterval
328    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwFrameInterval
329    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMaxBitRate
330    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMaxVideoFrameBufferSize
331    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/dwMinBitRate
332    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wHeight
333    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/480p/wWidth
334    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p
335    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/bFrameIndex
336    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/bmCapabilities
337    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwDefaultFrameInterval
338    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwFrameInterval
339    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMaxBitRate
340    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize
341    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/dwMinBitRate
342    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wHeight
343    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/720p/wWidth
344    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bAspectRatioX
345    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bAspectRatioY
346    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bDefaultFrameIndex
347    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bFormatIndex
348    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmaControls
349    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmFlags
350    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/mjpeg/m/bmInterlaceFlags
351    chown system system /config/usb_gadget/g1/functions/uvc.0/streaming/uncompressed
352    chown system system /config/usb_gadget/g1/idProduct
353    chown system system /config/usb_gadget/g1/idVendor
354    chown system system /config/usb_gadget/g1/max_speed
355    chown system system /config/usb_gadget/g1/os_desc
356    chown system system /config/usb_gadget/g1/os_desc/b.1
357    chown system system /config/usb_gadget/g1/os_desc/b_vendor_code
358    chown system system /config/usb_gadget/g1/os_desc/qw_sign
359    chown system system /config/usb_gadget/g1/os_desc/use
360    chown system system /config/usb_gadget/g1/strings
361    chown system system /config/usb_gadget/g1/strings/0x409
362    chown system system /config/usb_gadget/g1/strings/0x409/manufacturer
363    chown system system /config/usb_gadget/g1/strings/0x409/product
364    chown system system /config/usb_gadget/g1/strings/0x409/serialnumber
365    setprop vendor.usb.functions.ready 1
366
367on boot
368    write /config/usb_gadget/g1/bcdDevice 0x0510
369    # Use USB Gadget HAL
370    setprop sys.usb.configfs 2
371    # Enable in-kernel media-presence polling for SD cards
372    write /sys/module/block/parameters/events_dfl_poll_msecs 2000
373
374on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
375    write /config/usb_gadget/g1/idProduct 0x4EE7
376    write /config/usb_gadget/g1/idVendor 0x18D1
377
378on property:vendor.usb.config=*
379   start usbd
380
381on property:persist.vendor.usb.usbradio.config=*
382   start usbd
383
384on charger
385    mkdir /config/usb_gadget/g1
386    mkdir /config/usb_gadget/g1/strings/0x409
387    mkdir /config/usb_gadget/g1/configs/b.1
388    write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
389    write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
390    write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
391    write /config/usb_gadget/g1/configs/b.1/MaxPower 0x384
392    write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
393    write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
394    write /config/usb_gadget/g1/bcdDevice 0x0510
395    mkdir /config/usb_gadget/g1/functions/midi.gs5
396    symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
397    setprop sys.usb.controller "11110000.dwc3"
398    setprop sys.usb.configfs 1
399
400on property:ro.bootmode=charger
401    setprop sys.usb.config charger
402
403on property:sys.usb.config=charger && property:sys.usb.configfs=1
404    write /config/usb_gadget/g1/idVendor 0x18d1
405    write /config/usb_gadget/g1/idProduct 0x4eea
406    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "midi"
407    symlink /config/usb_gadget/g1/functions/midi.gs5 /config/usb_gadget/g1/configs/b.1/f1
408    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
409    write /sys/class/typec/port0/device/update_sdp_enum_timeout 0x1
410    setprop sys.usb.state ${sys.usb.config}
411
412on property:vendor.usb.contaminantdisable=true
413    exec /vendor/bin/hw/disable_contaminant_detection.sh
414
415on property:ro.bootmode=usbuwb
416    setprop persist.vendor.usb.usbradio.config uwb_acm
417