1# 2# Copyright (C) 2016 The Android Open-Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17on early-boot 18 mkdir /config/usb_gadget/g1 0770 19 mkdir /config/usb_gadget/g1/strings/0x409 0770 20 write /config/usb_gadget/g1/bcdUSB 0x0200 21 write /config/usb_gadget/g1/idVendor 0x18d1 22 write /config/usb_gadget/g1/bcdDevice 0x0440 23 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} 24 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} 25 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} 26 mkdir /config/usb_gadget/g1/functions/accessory.gs2 27 mkdir /config/usb_gadget/g1/functions/audio_source.gs3 28 mkdir /config/usb_gadget/g1/functions/midi.gs5 29 mkdir /config/usb_gadget/g1/functions/ffs.adb 30 mkdir /config/usb_gadget/g1/functions/ffs.mtp 31 mkdir /config/usb_gadget/g1/functions/ffs.ptp 32 mkdir /config/usb_gadget/g1/functions/diag.diag 33 mkdir /config/usb_gadget/g1/functions/diag.diag_mdm 34 mkdir /config/usb_gadget/g1/functions/cser.dun.0 35 mkdir /config/usb_gadget/g1/functions/cser.nmea.1 36 mkdir /config/usb_gadget/g1/functions/gsi.rmnet 37 mkdir /config/usb_gadget/g1/functions/gsi.rndis 38 mkdir /config/usb_gadget/g1/functions/gsi.dpl 39 mkdir /config/usb_gadget/g1/functions/qdss.qdss 40 mkdir /config/usb_gadget/g1/functions/qdss.qdss_mdm 41 mkdir /config/usb_gadget/g1/configs/b.1 0770 42 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 43 write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1 44 write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100" 45 mkdir /dev/usb-ffs 0775 shell shell 46 mkdir /dev/usb-ffs/adb 0770 shell shell 47 mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1 48 mkdir /dev/usb-ffs/mtp 0770 mtp mtp 49 mkdir /dev/usb-ffs/ptp 0770 mtp mtp 50 mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 51 mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 52 setprop sys.usb.mtp.device_type 3 53 setprop sys.usb.controller "a600000.dwc3" 54 symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 55 write /sys/module/libcomposite/parameters/disable_l1_for_hs "y" 56 write /config/usb_gadget/g1/functions/gsi.rndis/rndis_class_id 1 57 58 # chown file/folder permission 59 chown system system /config/usb_gadget/ 60 chown system system /config/usb_gadget/g1 61 chown system system /config/usb_gadget/g1/UDC 62 chown system system /config/usb_gadget/g1/bDeviceClass 63 chown system system /config/usb_gadget/g1/bDeviceProtocol 64 chown system system /config/usb_gadget/g1/bDeviceSubClass 65 chown system system /config/usb_gadget/g1/bMaxPacketSize0 66 chown system system /config/usb_gadget/g1/bcdDevice 67 chown system system /config/usb_gadget/g1/bcdUSB 68 chown system system /config/usb_gadget/g1/configs 69 chown system system /config/usb_gadget/g1/configs/b.1 70 chown system system /config/usb_gadget/g1/configs/b.1/MaxPower 71 chown system system /config/usb_gadget/g1/configs/b.1/bmAttributes 72 chown system system /config/usb_gadget/g1/configs/b.1/strings 73 chown system system /config/usb_gadget/g1/functions 74 chown system system /config/usb_gadget/g1/functions/accessory.gs2 75 chown system system /config/usb_gadget/g1/functions/audio_source.gs3 76 chown system system /config/usb_gadget/g1/functions/cser.dun.0 77 chown system system /config/usb_gadget/g1/functions/cser.dun.0/status 78 chown system system /config/usb_gadget/g1/functions/cser.nmea.1 79 chown system system /config/usb_gadget/g1/functions/cser.nmea.1/status 80 chown system system /config/usb_gadget/g1/functions/diag.diag 81 chown system system /config/usb_gadget/g1/functions/diag.diag_mdm 82 chown system system /config/usb_gadget/g1/functions/ffs.adb 83 chown system system /config/usb_gadget/g1/functions/ffs.mtp 84 chown system system /config/usb_gadget/g1/functions/ffs.ptp 85 chown system system /config/usb_gadget/g1/functions/gsi.dpl 86 chown system system /config/usb_gadget/g1/functions/gsi.dpl/info 87 chown system system /config/usb_gadget/g1/functions/gsi.rmnet 88 chown system system /config/usb_gadget/g1/functions/gsi.rmnet/info 89 chown system system /config/usb_gadget/g1/functions/gsi.rndis 90 chown system system /config/usb_gadget/g1/functions/gsi.rndis/info 91 chown system system /config/usb_gadget/g1/functions/gsi.rndis/rndis_class_id 92 chown system system /config/usb_gadget/g1/functions/midi.gs5 93 chown system system /config/usb_gadget/g1/functions/midi.gs5/buflen 94 chown system system /config/usb_gadget/g1/functions/midi.gs5/id 95 chown system system /config/usb_gadget/g1/functions/midi.gs5/in_ports 96 chown system system /config/usb_gadget/g1/functions/midi.gs5/index 97 chown system system /config/usb_gadget/g1/functions/midi.gs5/out_ports 98 chown system system /config/usb_gadget/g1/functions/midi.gs5/qlen 99 chown system system /config/usb_gadget/g1/functions/qdss.qdss 100 chown system system /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 101 chown system system /config/usb_gadget/g1/functions/qdss.qdss_mdm 102 chown system system /config/usb_gadget/g1/functions/qdss.qdss_mdm/enable_debug_inface 103 chown system system /config/usb_gadget/g1/idProduct 104 chown system system /config/usb_gadget/g1/idVendor 105 chown system system /config/usb_gadget/g1/os_desc 106 chown system system /config/usb_gadget/g1/os_desc/b.1 107 chown system system /config/usb_gadget/g1/os_desc/b.1/MaxPower 108 chown system system /config/usb_gadget/g1/os_desc/b.1/bmAttributes 109 chown system system /config/usb_gadget/g1/os_desc/b.1/strings 110 chown system system /config/usb_gadget/g1/os_desc/b.1/strings/0x409 111 chown system system /config/usb_gadget/g1/os_desc/b.1/strings/0x409/configuration 112 chown system system /config/usb_gadget/g1/os_desc/b_vendor_code 113 chown system system /config/usb_gadget/g1/os_desc/qw_sign 114 chown system system /config/usb_gadget/g1/os_desc/use 115 chown system system /config/usb_gadget/g1/strings 116 chown system system /config/usb_gadget/g1/strings/0x409 117 chown system system /config/usb_gadget/g1/strings/0x409/manufacturer 118 chown system system /config/usb_gadget/g1/strings/0x409/product 119 chown system system /config/usb_gadget/g1/strings/0x409/serialnumber 120 121on property:init.svc.console=running 122 write /sys/class/power_supply/usb/moisture_detection_enabled 0 123 124on property:init.svc.vendor.charger=running 125 write /sys/class/typec/port0/port_type sink 126 127on property:vendor.usb.contaminantdisable=true 128 write /sys/class/power_supply/usb/moisture_detection_enabled 0 129 130on boot 131 setprop sys.usb.configfs 2 132 133on property:sys.usb.config=none && property:sys.usb.configfs=1 134 rm /config/usb_gadget/g1/configs/b.1/f1 135 rm /config/usb_gadget/g1/configs/b.1/f2 136 rm /config/usb_gadget/g1/configs/b.1/f3 137 rm /config/usb_gadget/g1/configs/b.1/f4 138 rm /config/usb_gadget/g1/configs/b.1/f5 139 rm /config/usb_gadget/g1/configs/b.1/f6 140 rm /config/usb_gadget/g1/configs/b.1/f7 141 rm /config/usb_gadget/g1/configs/b.1/f8 142 rm /config/usb_gadget/g1/configs/b.1/f9 143 144on charger 145 mkdir /config/usb_gadget/g1 0770 146 mkdir /config/usb_gadget/g1/strings/0x409 0770 147 write /config/usb_gadget/g1/bcdUSB 0x0200 148 write /config/usb_gadget/g1/idVendor 0x18d1 149 write /config/usb_gadget/g1/bcdDevice 0x0440 150 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} 151 write /config/usb_gadget/g1/strings/0x409/manufacturer Google 152 write /config/usb_gadget/g1/strings/0x409/product Pixel 153 mkdir /config/usb_gadget/g1/functions/midi.gs5 154 mkdir /config/usb_gadget/g1/configs/b.1 0770 155 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 156 symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 157 setprop sys.usb.controller "a600000.dwc3" 158 159on property:ro.bootmode=charger 160 setprop sys.usb.config midi 161 162on property:sys.usb.config=midi && property:sys.usb.configfs=1 163 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "midi" 164 rm /config/usb_gadget/g1/configs/b.1/f1 165 rm /config/usb_gadget/g1/configs/b.1/f2 166 rm /config/usb_gadget/g1/configs/b.1/f3 167 rm /config/usb_gadget/g1/configs/b.1/f4 168 write /config/usb_gadget/g1/idVendor 0x18d1 169 write /config/usb_gadget/g1/idProduct 0x4eea 170 symlink /config/usb_gadget/g1/functions/midi.gs5 /config/usb_gadget/g1/configs/b.1/f1 171 write /config/usb_gadget/g1/UDC ${sys.usb.controller} 172 setprop sys.usb.state ${sys.usb.config} 173