blob: f0681d2c240972384f25ccbacbbef733149b9c5f [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 Tsai7b9a4d52017-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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070021on boot
22 setprop sys.usb.configfs 0
23
Mike Lockwood4f5d5172012-04-04 11:26:59 -070024# Used to disable USB when switching states
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070025on property:sys.usb.config=none && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070026 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
Badhri Jagan Sridharan97b536f2014-09-05 11:10:09 -070032# This is the fallback configuration if the
33# USB manager fails to set a standard configuration
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070034on property:sys.usb.config=adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070035 write /sys/class/android_usb/android0/enable 0
36 write /sys/class/android_usb/android0/idVendor 18d1
Badhri Jagan Sridharan97b536f2014-09-05 11:10:09 -070037 write /sys/class/android_usb/android0/idProduct 4EE7
Mike Lockwood4f5d5172012-04-04 11:26:59 -070038 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070044on property:sys.usb.config=accessory && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070045 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070053on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070054 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070063on property:sys.usb.config=audio_source && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070064 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070072on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070073 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070082on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070083 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
Badhri Jagan Sridharan48d59ac2015-08-28 17:39:28 -070091on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0
Mike Lockwood4f5d5172012-04-04 11:26:59 -070092 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
Badhri Jagan Sridharan05e04a12016-08-01 14:45:18 -0700102on boot && property:persist.sys.usb.config=*
Mike Lockwood4f5d5172012-04-04 11:26:59 -0700103 setprop sys.usb.config ${persist.sys.usb.config}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700104
105#
106# USB type C
107#
108
109# USB mode changes
110on 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
114on 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
119on property:sys.usb.typec.data_role=device
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700120 write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700121 setprop sys.usb.typec.state ${sys.usb.typec.data_role}
122
123on property:sys.usb.typec.data_role=host
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
127# USB power role changes
128on property:sys.usb.typec.power_role=source
Vincent Palatin3b7995b2015-09-03 13:50:27 -0700129 write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
Tim Kilbourn8c12fdf2015-08-12 09:36:00 -0700130 setprop sys.usb.typec.state ${sys.usb.typec.power_role}
131
132on property:sys.usb.typec.power_role=sink
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}