Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Tom Cherry | 2270dbb | 2015-09-03 16:14:51 -0700 | [diff] [blame] | 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 |
Bowgo Tsai | 7b9a4d5 | 2017-07-28 20:29:15 +0800 | [diff] [blame] | 15 | service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 |
Tom Cherry | 2270dbb | 2015-09-03 16:14:51 -0700 | [diff] [blame] | 16 | class core |
| 17 | socket adbd stream 660 system system |
| 18 | disabled |
| 19 | seclabel u:r:adbd:s0 |
| 20 | |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 21 | on boot |
| 22 | setprop sys.usb.configfs 0 |
| 23 | |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 24 | # Used to disable USB when switching states |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 25 | on property:sys.usb.config=none && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 97b536f | 2014-09-05 11:10:09 -0700 | [diff] [blame] | 32 | # This is the fallback configuration if the |
| 33 | # USB manager fails to set a standard configuration |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 34 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 35 | write /sys/class/android_usb/android0/enable 0 |
| 36 | write /sys/class/android_usb/android0/idVendor 18d1 |
Badhri Jagan Sridharan | 97b536f | 2014-09-05 11:10:09 -0700 | [diff] [blame] | 37 | write /sys/class/android_usb/android0/idProduct 4EE7 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 44 | on property:sys.usb.config=accessory && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 53 | on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 63 | on property:sys.usb.config=audio_source && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 72 | on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 82 | on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 91 | on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 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 |
Badhri Jagan Sridharan | 05e04a1 | 2016-08-01 14:45:18 -0700 | [diff] [blame] | 102 | on boot && property:persist.sys.usb.config=* |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 103 | setprop sys.usb.config ${persist.sys.usb.config} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 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 |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 120 | write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 121 | setprop sys.usb.typec.state ${sys.usb.typec.data_role} |
| 122 | |
| 123 | on property:sys.usb.typec.data_role=host |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 124 | write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 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 |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 129 | write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 130 | setprop sys.usb.typec.state ${sys.usb.typec.power_role} |
| 131 | |
| 132 | on property:sys.usb.typec.power_role=sink |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 133 | write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 134 | setprop sys.usb.typec.state ${sys.usb.typec.power_role} |