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 |
| 15 | service adbd /sbin/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 | # adbd on at boot in emulator |
| 22 | on property:ro.kernel.qemu=1 |
| 23 | start adbd |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 24 | |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 25 | on boot |
| 26 | setprop sys.usb.configfs 0 |
| 27 | |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 28 | # Used to disable USB when switching states |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 29 | on property:sys.usb.config=none && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 30 | 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 Sridharan | 97b536f | 2014-09-05 11:10:09 -0700 | [diff] [blame] | 36 | # This is the fallback configuration if the |
| 37 | # USB manager fails to set a standard configuration |
Badhri Jagan Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 38 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 39 | write /sys/class/android_usb/android0/enable 0 |
| 40 | write /sys/class/android_usb/android0/idVendor 18d1 |
Badhri Jagan Sridharan | 97b536f | 2014-09-05 11:10:09 -0700 | [diff] [blame] | 41 | write /sys/class/android_usb/android0/idProduct 4EE7 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 42 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 48 | on property:sys.usb.config=accessory && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 49 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 57 | on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 58 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 67 | on property:sys.usb.config=audio_source && property:sys.usb.configfs=0 |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 68 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 76 | 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] | 77 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 86 | 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] | 87 | 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 Sridharan | 48d59ac | 2015-08-28 17:39:28 -0700 | [diff] [blame] | 95 | 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] | 96 | 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 Sridharan | 05e04a1 | 2016-08-01 14:45:18 -0700 | [diff] [blame] | 106 | on boot && property:persist.sys.usb.config=* |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 107 | setprop sys.usb.config ${persist.sys.usb.config} |
Tim Kilbourn | 8c12fdf | 2015-08-12 09:36:00 -0700 | [diff] [blame] | 108 | |
| 109 | # |
| 110 | # USB type C |
| 111 | # |
| 112 | |
| 113 | # USB mode changes |
| 114 | on 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 | |
| 118 | on 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 |
| 123 | on property:sys.usb.typec.data_role=device |
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 | on property:sys.usb.typec.data_role=host |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 128 | 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] | 129 | setprop sys.usb.typec.state ${sys.usb.typec.data_role} |
| 130 | |
| 131 | # USB power role changes |
| 132 | on property:sys.usb.typec.power_role=source |
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} |
| 135 | |
| 136 | on property:sys.usb.typec.power_role=sink |
Vincent Palatin | 3b7995b | 2015-09-03 13:50:27 -0700 | [diff] [blame] | 137 | 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] | 138 | setprop sys.usb.typec.state ${sys.usb.typec.power_role} |