1# Copyright (C) 2012 The Android Open Source Project 2# 3# USB configuration common for all android devices 4# 5 6on post-fs-data 7 chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file 8 chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file 9 chown system system /sys/class/android_usb/android0/f_rndis/ethaddr 10 chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr 11 mkdir /data/misc/adb 02750 system shell 12 mkdir /data/adb 0700 root root encryption=Require 13 14# adbd is controlled via property triggers in init.<platform>.usb.rc 15service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 16 class core 17 socket adbd seqpacket 660 system system 18 disabled 19 updatable 20 seclabel u:r:adbd:s0 21 22on property:vendor.sys.usb.adb.disabled=* 23 setprop sys.usb.adb.disabled ${vendor.sys.usb.adb.disabled} 24 25# Set default value on sys.usb.configfs early in boot sequence. It will be 26# overridden in `on boot` action of init.hardware.rc. 27on init 28 setprop sys.usb.configfs 0 29 30# Used to disable USB when switching states 31on property:sys.usb.config=none && property:sys.usb.configfs=0 32 stop adbd 33 write /sys/class/android_usb/android0/enable 0 34 write /sys/class/android_usb/android0/bDeviceClass 0 35 setprop sys.usb.state ${sys.usb.config} 36 37# adb only USB configuration 38# This is the fallback configuration if the 39# USB manager fails to set a standard configuration 40on property:sys.usb.config=adb && property:sys.usb.configfs=0 41 write /sys/class/android_usb/android0/enable 0 42 write /sys/class/android_usb/android0/idVendor 18d1 43 write /sys/class/android_usb/android0/idProduct 4EE7 44 write /sys/class/android_usb/android0/functions ${sys.usb.config} 45 write /sys/class/android_usb/android0/enable 1 46 start adbd 47 setprop sys.usb.state ${sys.usb.config} 48 49# USB accessory configuration 50on property:sys.usb.config=accessory && property:sys.usb.configfs=0 51 write /sys/class/android_usb/android0/enable 0 52 write /sys/class/android_usb/android0/idVendor 18d1 53 write /sys/class/android_usb/android0/idProduct 2d00 54 write /sys/class/android_usb/android0/functions ${sys.usb.config} 55 write /sys/class/android_usb/android0/enable 1 56 setprop sys.usb.state ${sys.usb.config} 57 58# USB accessory configuration, with adb 59on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0 60 write /sys/class/android_usb/android0/enable 0 61 write /sys/class/android_usb/android0/idVendor 18d1 62 write /sys/class/android_usb/android0/idProduct 2d01 63 write /sys/class/android_usb/android0/functions ${sys.usb.config} 64 write /sys/class/android_usb/android0/enable 1 65 start adbd 66 setprop sys.usb.state ${sys.usb.config} 67 68# audio accessory configuration 69on property:sys.usb.config=audio_source && property:sys.usb.configfs=0 70 write /sys/class/android_usb/android0/enable 0 71 write /sys/class/android_usb/android0/idVendor 18d1 72 write /sys/class/android_usb/android0/idProduct 2d02 73 write /sys/class/android_usb/android0/functions ${sys.usb.config} 74 write /sys/class/android_usb/android0/enable 1 75 setprop sys.usb.state ${sys.usb.config} 76 77# audio accessory configuration, with adb 78on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0 79 write /sys/class/android_usb/android0/enable 0 80 write /sys/class/android_usb/android0/idVendor 18d1 81 write /sys/class/android_usb/android0/idProduct 2d03 82 write /sys/class/android_usb/android0/functions ${sys.usb.config} 83 write /sys/class/android_usb/android0/enable 1 84 start adbd 85 setprop sys.usb.state ${sys.usb.config} 86 87# USB and audio accessory configuration 88on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0 89 write /sys/class/android_usb/android0/enable 0 90 write /sys/class/android_usb/android0/idVendor 18d1 91 write /sys/class/android_usb/android0/idProduct 2d04 92 write /sys/class/android_usb/android0/functions ${sys.usb.config} 93 write /sys/class/android_usb/android0/enable 1 94 setprop sys.usb.state ${sys.usb.config} 95 96# USB and audio accessory configuration, with adb 97on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0 98 write /sys/class/android_usb/android0/enable 0 99 write /sys/class/android_usb/android0/idVendor 18d1 100 write /sys/class/android_usb/android0/idProduct 2d05 101 write /sys/class/android_usb/android0/functions ${sys.usb.config} 102 write /sys/class/android_usb/android0/enable 1 103 start adbd 104 setprop sys.usb.state ${sys.usb.config} 105 106# Used to set USB configuration at boot and to switch the configuration 107# when changing the default configuration 108on boot && property:persist.sys.usb.config=* 109 setprop sys.usb.config ${persist.sys.usb.config} 110 111# 112# USB type C 113# 114 115# USB mode changes 116on property:sys.usb.typec.mode=dfp 117 write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode} 118 setprop sys.usb.typec.state ${sys.usb.typec.mode} 119 120on property:sys.usb.typec.mode=ufp 121 write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode} 122 setprop sys.usb.typec.state ${sys.usb.typec.mode} 123 124# USB data role changes 125on property:sys.usb.typec.data_role=device 126 write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role} 127 setprop sys.usb.typec.state ${sys.usb.typec.data_role} 128 129on property:sys.usb.typec.data_role=host 130 write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role} 131 setprop sys.usb.typec.state ${sys.usb.typec.data_role} 132 133# USB power role changes 134on property:sys.usb.typec.power_role=source 135 write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role} 136 setprop sys.usb.typec.state ${sys.usb.typec.power_role} 137 138on property:sys.usb.typec.power_role=sink 139 write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role} 140 setprop sys.usb.typec.state ${sys.usb.typec.power_role} 141 142on userspace-reboot-requested 143 setprop sys.usb.config "" 144 setprop sys.usb.state "" 145