2012-04-05 02:26:59 +08:00
|
|
|
# Copyright (C) 2012 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# USB configuration common for all android devices
|
|
|
|
#
|
|
|
|
|
|
|
|
on post-fs-data
|
|
|
|
chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
|
|
|
|
chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
|
|
|
|
chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
|
|
|
|
chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
|
2015-09-04 07:14:51 +08:00
|
|
|
mkdir /data/misc/adb 02750 system shell
|
|
|
|
mkdir /data/adb 0700 root root
|
|
|
|
|
|
|
|
# adbd is controlled via property triggers in init.<platform>.usb.rc
|
|
|
|
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
|
|
|
|
class core
|
|
|
|
socket adbd stream 660 system system
|
|
|
|
disabled
|
|
|
|
seclabel u:r:adbd:s0
|
|
|
|
|
|
|
|
# adbd on at boot in emulator
|
|
|
|
on property:ro.kernel.qemu=1
|
|
|
|
start adbd
|
2012-04-05 02:26:59 +08:00
|
|
|
|
2015-08-29 08:39:28 +08:00
|
|
|
on boot
|
|
|
|
setprop sys.usb.configfs 0
|
|
|
|
|
2012-04-05 02:26:59 +08:00
|
|
|
# Used to disable USB when switching states
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=none && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
stop adbd
|
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/bDeviceClass 0
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# adb only USB configuration
|
2014-09-06 02:10:09 +08:00
|
|
|
# This is the fallback configuration if the
|
|
|
|
# USB manager fails to set a standard configuration
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=adb && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
2014-09-06 02:10:09 +08:00
|
|
|
write /sys/class/android_usb/android0/idProduct 4EE7
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
start adbd
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# USB accessory configuration
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=accessory && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d00
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# USB accessory configuration, with adb
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d01
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
start adbd
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# audio accessory configuration
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=audio_source && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d02
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# audio accessory configuration, with adb
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d03
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
start adbd
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# USB and audio accessory configuration
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d04
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# USB and audio accessory configuration, with adb
|
2015-08-29 08:39:28 +08:00
|
|
|
on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0
|
2012-04-05 02:26:59 +08:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
|
|
|
write /sys/class/android_usb/android0/idProduct 2d05
|
|
|
|
write /sys/class/android_usb/android0/functions ${sys.usb.config}
|
|
|
|
write /sys/class/android_usb/android0/enable 1
|
|
|
|
start adbd
|
|
|
|
setprop sys.usb.state ${sys.usb.config}
|
|
|
|
|
|
|
|
# Used to set USB configuration at boot and to switch the configuration
|
|
|
|
# when changing the default configuration
|
|
|
|
on property:persist.sys.usb.config=*
|
|
|
|
setprop sys.usb.config ${persist.sys.usb.config}
|
2015-08-13 00:36:00 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# USB type C
|
|
|
|
#
|
|
|
|
|
|
|
|
# USB mode changes
|
|
|
|
on property:sys.usb.typec.mode=dfp
|
|
|
|
write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode}
|
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.mode}
|
|
|
|
|
|
|
|
on property:sys.usb.typec.mode=ufp
|
|
|
|
write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode}
|
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.mode}
|
|
|
|
|
|
|
|
# USB data role changes
|
|
|
|
on property:sys.usb.typec.data_role=device
|
2015-09-04 04:50:27 +08:00
|
|
|
write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
|
2015-08-13 00:36:00 +08:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.data_role}
|
|
|
|
|
|
|
|
on property:sys.usb.typec.data_role=host
|
2015-09-04 04:50:27 +08:00
|
|
|
write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
|
2015-08-13 00:36:00 +08:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.data_role}
|
|
|
|
|
|
|
|
# USB power role changes
|
|
|
|
on property:sys.usb.typec.power_role=source
|
2015-09-04 04:50:27 +08:00
|
|
|
write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
|
2015-08-13 00:36:00 +08:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.power_role}
|
|
|
|
|
|
|
|
on property:sys.usb.typec.power_role=sink
|
2015-09-04 04:50:27 +08:00
|
|
|
write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
|
2015-08-13 00:36:00 +08:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.power_role}
|