blob: 9d2ac02a69ac9bf4999d3d721c90c77d715941dd [file] [log] [blame]
on early-boot
mkdir /config/usb_gadget/g1
mkdir /config/usb_gadget/g1/strings/0x409
mkdir /config/usb_gadget/g1/configs/b.1
write /config/usb_gadget/g1/idVendor 0x18d1
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
write /config/usb_gadget/g1/configs/b.1/MaxPower 0x384
write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
# ffs function
mkdir /config/usb_gadget/g1/functions/ffs.adb 0770 shell shell
mkdir /config/usb_gadget/g1/functions/ffs.mtp
mkdir /config/usb_gadget/g1/functions/ffs.ptp
mkdir /dev/usb-ffs 0775 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mkdir /dev/usb-ffs/mtp 0770 mtp mtp
mkdir /dev/usb-ffs/ptp 0770 mtp mtp
mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1
mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
setprop sys.usb.mtp.device_type 3
setprop sys.usb.mtp.batchcancel true
symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
# mtp function
mkdir /config/usb_gadget/g1/functions/mtp.gs0
# ptp function
mkdir /config/usb_gadget/g1/functions/ptp.gs1
# accessory function
mkdir /config/usb_gadget/g1/functions/accessory.gs2
# audio_source function
mkdir /config/usb_gadget/g1/functions/audio_source.gs3
# rndis function
mkdir /config/usb_gadget/g1/functions/rndis.gs4
# Modify class/subclass/protocol for rndis.gs4
# Remote NDIS: Class: Wireless Controller (0xe0), Subclass: 0x1, Protocol: 0x3
write /config/usb_gadget/g1/functions/rndis.gs4/class e0
write /config/usb_gadget/g1/functions/rndis.gs4/subclass 01
write /config/usb_gadget/g1/functions/rndis.gs4/protocol 03
write /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.ncm/compatible_id RNDIS
write /config/usb_gadget/g1/functions/rndis.gs4/ifname rndis%d
setprop vendor.usb.rndis.config rndis.gs4
# midi function
mkdir /config/usb_gadget/g1/functions/midi.gs5
# acm function
mkdir /config/usb_gadget/g1/functions/acm.gs6
# dm function
mkdir /config/usb_gadget/g1/functions/dm.gs7
# uts function
mkdir /config/usb_gadget/g1/functions/uts.gs8
# ncm function
mkdir /config/usb_gadget/g1/functions/ncm.gs9
write /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/compatible_id WINNCM
write /config/usb_gadget/g1/functions/ncm.gs9/ifname ncm%d
# chown file/folder permission
chown system system /config/usb_gadget/
chown system system /config/usb_gadget/g1
chown system system /config/usb_gadget/g1/UDC
chown system system /config/usb_gadget/g1/bDeviceClass
chown system system /config/usb_gadget/g1/bDeviceProtocol
chown system system /config/usb_gadget/g1/bDeviceSubClass
chown system system /config/usb_gadget/g1/bMaxPacketSize0
chown system system /config/usb_gadget/g1/bcdDevice
chown system system /config/usb_gadget/g1/bcdUSB
chown system system /config/usb_gadget/g1/configs
chown system system /config/usb_gadget/g1/configs/b.1
chown system system /config/usb_gadget/g1/configs/b.1/MaxPower
chown system system /config/usb_gadget/g1/configs/b.1/bmAttributes
chown system system /config/usb_gadget/g1/configs/b.1/strings
chown system system /config/usb_gadget/g1/functions
chown system system /config/usb_gadget/g1/functions/accessory.gs2
chown system system /config/usb_gadget/g1/functions/acm.gs6
chown system system /config/usb_gadget/g1/functions/acm.gs6/port_num
chown system system /config/usb_gadget/g1/functions/audio_source.gs3
chown system system /config/usb_gadget/g1/functions/dm.gs7
chown system system /config/usb_gadget/g1/functions/ffs.adb
chown system system /config/usb_gadget/g1/functions/ffs.mtp
chown system system /config/usb_gadget/g1/functions/ffs.ptp
chown system system /config/usb_gadget/g1/functions/midi.gs5
chown system system /config/usb_gadget/g1/functions/midi.gs5/buflen
chown system system /config/usb_gadget/g1/functions/midi.gs5/id
chown system system /config/usb_gadget/g1/functions/midi.gs5/in_ports
chown system system /config/usb_gadget/g1/functions/midi.gs5/index
chown system system /config/usb_gadget/g1/functions/midi.gs5/out_ports
chown system system /config/usb_gadget/g1/functions/midi.gs5/qlen
chown system system /config/usb_gadget/g1/functions/mtp.gs0
chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc
chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP
chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/compatible_id
chown system system /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/sub_compatible_id
chown system system /config/usb_gadget/g1/functions/ncm.gs9
chown system system /config/usb_gadget/g1/functions/ncm.gs9/dev_addr
chown system system /config/usb_gadget/g1/functions/ncm.gs9/host_addr
chown system system /config/usb_gadget/g1/functions/ncm.gs9/ifname
chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc
chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm
chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/compatible_id
chown system system /config/usb_gadget/g1/functions/ncm.gs9/os_desc/interface.ncm/sub_compatible_id
chown system system /config/usb_gadget/g1/functions/ncm.gs9/qmult
chown system system /config/usb_gadget/g1/functions/ptp.gs1
chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc
chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP
chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/compatible_id
chown system system /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/sub_compatible_id
chown system system /config/usb_gadget/g1/functions/rndis.gs4
chown system system /config/usb_gadget/g1/functions/rndis.gs4/class
chown system system /config/usb_gadget/g1/functions/rndis.gs4/dev_addr
chown system system /config/usb_gadget/g1/functions/rndis.gs4/host_addr
chown system system /config/usb_gadget/g1/functions/rndis.gs4/ifname
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/compatible_id
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/sub_compatible_id
chown system system /config/usb_gadget/g1/functions/rndis.gs4/protocol
chown system system /config/usb_gadget/g1/functions/rndis.gs4/qmult
chown system system /config/usb_gadget/g1/functions/rndis.gs4/subclass
chown system system /config/usb_gadget/g1/idProduct
chown system system /config/usb_gadget/g1/idVendor
chown system system /config/usb_gadget/g1/max_speed
chown system system /config/usb_gadget/g1/os_desc
chown system system /config/usb_gadget/g1/os_desc/b.1
chown system system /config/usb_gadget/g1/os_desc/b_vendor_code
chown system system /config/usb_gadget/g1/os_desc/qw_sign
chown system system /config/usb_gadget/g1/os_desc/use
chown system system /config/usb_gadget/g1/strings
chown system system /config/usb_gadget/g1/strings/0x409
chown system system /config/usb_gadget/g1/strings/0x409/manufacturer
chown system system /config/usb_gadget/g1/strings/0x409/product
chown system system /config/usb_gadget/g1/strings/0x409/serialnumber
setprop vendor.usb.functions.ready 1
on boot
write /config/usb_gadget/g1/bcdDevice 0x0414
# Use USB Gadget HAL
setprop sys.usb.configfs 2
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
write /config/usb_gadget/g1/idProduct 0x4EE7
write /config/usb_gadget/g1/idVendor 0x18D1