blob: 3168f40baed16124ab3992e97c381c968c098e7c [file] [log] [blame]
Mike Lockwood4f5d5172012-04-04 11:26:59 -07001# 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
Tom Cherry2270dbb2015-09-03 16:14:51 -070011 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
Bowgo Tsai93defc12017-07-28 20:29:15 +080015service adbd /system/bin/adbd --root_seclabel=u:r:su:s0
Tom Cherry2270dbb2015-09-03 16:14:51 -070016 class core
17 socket adbd stream 660 system system
18 disabled
19 seclabel u:r:adbd:s0
20
21# adbd on at boot in emulator
22on property:ro.kernel.qemu=1
23 start adbd
Mike Lockwood4f5d5172012-04-04 11:26:59 -070024
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070025on boot
26 setprop sys.usb.configfs 0
27
Mike Lockwood4f5d5172012-04-04 11:26:59 -070028# Used to disable USB when switching states
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070029on property:sys.usb.config=none && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070030 stop adbd
31 write /sys/class/android_usb/android0/enable 0
32 write /sys/class/android_usb/android0/bDeviceClass 0
33 setprop sys.usb.state ${sys.usb.config}
34
35# adb only USB configuration
Badhri Jagan Sridharan97b536f2014-09-05 11:10:09 -070036# This is the fallback configuration if the
37# USB manager fails to set a standard configuration
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070038on property:sys.usb.config=adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070039 write /sys/class/android_usb/android0/enable 0
40 write /sys/class/android_usb/android0/idVendor 18d1
Badhri Jagan Sridharan97b536f2014-09-05 11:10:09 -070041 write /sys/class/android_usb/android0/idProduct 4EE7
Mike Lockwood4f5d5172012-04-04 11:26:59 -070042 write /sys/class/android_usb/android0/functions ${sys.usb.config}
43 write /sys/class/android_usb/android0/enable 1
44 start adbd
45 setprop sys.usb.state ${sys.usb.config}
46
47# USB accessory configuration
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070048on property:sys.usb.config=accessory && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070049 write /sys/class/android_usb/android0/enable 0
50 write /sys/class/android_usb/android0/idVendor 18d1
51 write /sys/class/android_usb/android0/idProduct 2d00
52 write /sys/class/android_usb/android0/functions ${sys.usb.config}
53 write /sys/class/android_usb/android0/enable 1
54 setprop sys.usb.state ${sys.usb.config}
55
56# USB accessory configuration, with adb
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070057on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070058 write /sys/class/android_usb/android0/enable 0
59 write /sys/class/android_usb/android0/idVendor 18d1
60 write /sys/class/android_usb/android0/idProduct 2d01
61 write /sys/class/android_usb/android0/functions ${sys.usb.config}
62 write /sys/class/android_usb/android0/enable 1
63 start adbd
64 setprop sys.usb.state ${sys.usb.config}
65
66# audio accessory configuration
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070067on property:sys.usb.config=audio_source && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070068 write /sys/class/android_usb/android0/enable 0
69 write /sys/class/android_usb/android0/idVendor 18d1
70 write /sys/class/android_usb/android0/idProduct 2d02
71 write /sys/class/android_usb/android0/functions ${sys.usb.config}
72 write /sys/class/android_usb/android0/enable 1
73 setprop sys.usb.state ${sys.usb.config}
74
75# audio accessory configuration, with adb
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070076on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070077 write /sys/class/android_usb/android0/enable 0
78 write /sys/class/android_usb/android0/idVendor 18d1
79 write /sys/class/android_usb/android0/idProduct 2d03
80 write /sys/class/android_usb/android0/functions ${sys.usb.config}
81 write /sys/class/android_usb/android0/enable 1
82 start adbd
83 setprop sys.usb.state ${sys.usb.config}
84
85# USB and audio accessory configuration
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070086on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070087 write /sys/class/android_usb/android0/enable 0
88 write /sys/class/android_usb/android0/idVendor 18d1
89 write /sys/class/android_usb/android0/idProduct 2d04
90 write /sys/class/android_usb/android0/functions ${sys.usb.config}
91 write /sys/class/android_usb/android0/enable 1
92 setprop sys.usb.state ${sys.usb.config}
93
94# USB and audio accessory configuration, with adb
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070095on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070096 write /sys/class/android_usb/android0/enable 0
97 write /sys/class/android_usb/android0/idVendor 18d1
98 write /sys/class/android_usb/android0/idProduct 2d05
99 write /sys/class/android_usb/android0/functions ${sys.usb.config}
100 write /sys/class/android_usb/android0/enable 1
101 start adbd
102 setprop sys.usb.state ${sys.usb.config}
103
104# Used to set USB configuration at boot and to switch the configuration
105# when changing the default configuration
Badhri Jagan Sridharan05e04a12016-08-01 14:45:18 -0700106on boot && property:persist.sys.usb.config=*
Mike Lockwood4f5d5172012-04-04 11:26:59 -0700107 setprop sys.usb.config ${persist.sys.usb.config}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700108
109#
110# USB type C
111#
112
113# USB mode changes
114on property:sys.usb.typec.mode=dfp
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
118on property:sys.usb.typec.mode=ufp
119 write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode}
120 setprop sys.usb.typec.state ${sys.usb.typec.mode}
121
122# USB data role changes
123on property:sys.usb.typec.data_role=device
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700124 write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700125 setprop sys.usb.typec.state ${sys.usb.typec.data_role}
126
127on property:sys.usb.typec.data_role=host
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700128 write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700129 setprop sys.usb.typec.state ${sys.usb.typec.data_role}
130
131# USB power role changes
132on property:sys.usb.typec.power_role=source
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700133 write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700134 setprop sys.usb.typec.state ${sys.usb.typec.power_role}
135
136on property:sys.usb.typec.power_role=sink
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700137 write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700138 setprop sys.usb.typec.state ${sys.usb.typec.power_role}