| # Copyright 2014 The Android Open Source Project |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| on init |
| mkdir /dev/bus |
| mkdir /dev/bus/usb |
| mkdir /dev/bus/usb/001 |
| |
| # set usb serial number |
| write /sys/class/android_usb/android0/iSerial ${ro.serialno} |
| |
| on fs |
| mkdir /dev/usb-ffs 0770 shell shell |
| mkdir /dev/usb-ffs/adb 0770 shell shell |
| mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 |
| write /sys/class/android_usb/android0/f_ffs/aliases adb |
| |
| on post-fs-data |
| chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file |
| chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file |
| chown system system /sys/class/android_usb/android0/f_rndis/ethaddr |
| chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr |
| |
| # Used to disable USB when switching states |
| on property:sys.usb.config=none |
| stop adbd |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/bDeviceClass 0 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # adb only USB configuration |
| # This should only be used for debugging |
| on property:sys.usb.config=iadb |
| mkdir /dev/usb-ffs 0770 shell shell |
| mkdir /dev/usb-ffs/adb 0770 shell shell |
| mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 |
| write /sys/class/android_usb/android0/f_ffs/aliases adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a1f |
| write /sys/class/android_usb/android0/functions adb |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # this is charging only mode, no need to enable adbd |
| on property:sys.usb.config=charging |
| stop adbd |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a1f |
| write /sys/class/android_usb/android0/functions adb |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB accessory configuration |
| on property:sys.usb.config=accessory |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d00 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB accessory configuration, with adb |
| on property:sys.usb.config=accessory,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d01 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # audio accessory configuration |
| on property:sys.usb.config=audio_source |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d02 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # audio accessory configuration, with adb |
| on property:sys.usb.config=audio_source,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d03 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB and audio accessory configuration |
| on property:sys.usb.config=accessory,audio_source |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d04 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB and audio accessory configuration, with adb |
| on property:sys.usb.config=accessory,audio_source,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 18d1 |
| write /sys/class/android_usb/android0/idProduct 2d05 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB MTP configuration |
| on property:sys.usb.config=mtp |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a20 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB MTP configuration, with adb |
| on property:sys.usb.config=mtp,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a21 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 1 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB PTP configuration |
| on property:sys.usb.config=ptp |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a22 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB PTP configuration, with adb |
| on property:sys.usb.config=ptp,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a23 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 1 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| |
| # USB RNDIS configuration |
| on property:sys.usb.config=rndis |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a24 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 0 |
| write /sys/class/android_usb/android0/enable 1 |
| setprop sys.usb.state ${sys.usb.config} |
| wait /sys/class/net/rndis0/queues/rx-0/rps_cpus 1 |
| write /sys/class/net/rndis0/queues/rx-0/rps_cpus F |
| |
| # USB RNDIS configuration, with adb |
| on property:sys.usb.config=rndis,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a25 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 1 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| wait /sys/class/net/rndis0/queues/rx-0/rps_cpus 1 |
| write /sys/class/net/rndis0/queues/rx-0/rps_cpus F |
| |
| # USB ACM configuration, with rndis and adb |
| on property:sys.usb.config=rndis,acm,adb |
| write /sys/class/android_usb/android0/enable 0 |
| write /sys/class/android_usb/android0/idVendor 8087 |
| write /sys/class/android_usb/android0/idProduct 0a26 |
| write /sys/class/android_usb/android0/f_acm/instances 1 |
| write /sys/class/android_usb/android0/functions ${sys.usb.config} |
| write /sys/bus/pci/devices/0000:00:02.3/sdis 1 |
| write /sys/class/android_usb/android0/enable 1 |
| start adbd |
| setprop sys.usb.state ${sys.usb.config} |
| wait /sys/class/net/rndis0/queues/rx-0/rps_cpus 1 |
| write /sys/class/net/rndis0/queues/rx-0/rps_cpus F |
| |
| # Used to set USB configuration at boot and to switch the configuration |
| # when changing the default configuration |
| on property:persist.sys.usb.config=* |
| setprop sys.usb.config ${persist.sys.usb.config} |
| |
| # USB vBus status changed to normal |
| on property:sys.usb.vbus=normal |
| write /sys/class/usb_otg/otg0/a_bus_drop 0 |
| |
| # USB vBus status changed to warning |
| on property:sys.usb.vbus=warning |
| write /sys/class/usb_otg/otg0/a_bus_drop 0 |
| |
| # USB vBus status changed to critical |
| on property:sys.usb.vbus=critical |
| write /sys/class/usb_otg/otg0/a_bus_drop 1 |