• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15on init
16    mkdir /dev/bus
17    mkdir /dev/bus/usb
18    mkdir /dev/bus/usb/001
19
20    # set usb serial number
21    write /sys/class/android_usb/android0/iSerial ${ro.serialno}
22
23on fs
24    mkdir /dev/usb-ffs 0770 shell shell
25    mkdir /dev/usb-ffs/adb 0770 shell shell
26    mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
27    write /sys/class/android_usb/android0/f_ffs/aliases adb
28
29on post-fs-data
30    chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
31    chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
32    chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
33    chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
34
35# Used to disable USB when switching states
36on property:sys.usb.config=none
37    stop adbd
38    write /sys/class/android_usb/android0/enable 0
39    write /sys/class/android_usb/android0/bDeviceClass 0
40    setprop sys.usb.state ${sys.usb.config}
41
42# adb only
43on property:sys.usb.config=adb
44    write /sys/class/android_usb/android0/enable 0
45    write /sys/class/android_usb/android0/idVendor 18d1
46    write /sys/class/android_usb/android0/idProduct 4ee7
47    write /sys/class/android_usb/android0/functions ${sys.usb.config}
48    write /sys/bus/pci/devices/0000:00:02.3/sdis 0
49    write /sys/class/android_usb/android0/enable 1
50    start adbd
51    setprop sys.usb.state ${sys.usb.config}
52
53# Used to set USB configuration at boot and to switch the configuration
54# when changing the default configuration
55on property:persist.sys.usb.config=*
56    setprop sys.usb.config ${persist.sys.usb.config}
57
58# USB vBus status changed to normal
59on property:sys.usb.vbus=normal
60   write /sys/class/usb_otg/otg0/a_bus_drop 0
61
62# USB vBus status changed to warning
63on property:sys.usb.vbus=warning
64   write /sys/class/usb_otg/otg0/a_bus_drop 0
65
66# USB vBus status changed to critical
67on property:sys.usb.vbus=critical
68   write /sys/class/usb_otg/otg0/a_bus_drop 1
69