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