2012-04-04 20:26:59 +02: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 01:14:51 +02:00
|
|
|
mkdir /data/misc/adb 02750 system shell
|
2019-10-28 15:55:03 +01:00
|
|
|
mkdir /data/adb 0700 root root encryption=Require
|
2015-09-04 01:14:51 +02:00
|
|
|
|
|
|
|
# adbd is controlled via property triggers in init.<platform>.usb.rc
|
2017-07-28 14:29:15 +02:00
|
|
|
service adbd /system/bin/adbd --root_seclabel=u:r:su:s0
|
2015-09-04 01:14:51 +02:00
|
|
|
class core
|
2019-04-26 03:33:35 +02:00
|
|
|
socket adbd seqpacket 660 system system
|
2015-09-04 01:14:51 +02:00
|
|
|
disabled
|
2019-08-15 23:05:12 +02:00
|
|
|
updatable
|
2015-09-04 01:14:51 +02:00
|
|
|
seclabel u:r:adbd:s0
|
|
|
|
|
2019-12-10 20:16:15 +01:00
|
|
|
# Set default value on sys.usb.configfs early in boot sequence. It will be
|
|
|
|
# overridden in `on boot` action of init.hardware.rc.
|
|
|
|
on init
|
2015-08-29 02:39:28 +02:00
|
|
|
setprop sys.usb.configfs 0
|
|
|
|
|
2012-04-04 20:26:59 +02:00
|
|
|
# Used to disable USB when switching states
|
2015-08-29 02:39:28 +02:00
|
|
|
on property:sys.usb.config=none && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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-05 20:10:09 +02:00
|
|
|
# This is the fallback configuration if the
|
|
|
|
# USB manager fails to set a standard configuration
|
2015-08-29 02:39:28 +02:00
|
|
|
on property:sys.usb.config=adb && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02:00
|
|
|
write /sys/class/android_usb/android0/enable 0
|
|
|
|
write /sys/class/android_usb/android0/idVendor 18d1
|
2014-09-05 20:10:09 +02:00
|
|
|
write /sys/class/android_usb/android0/idProduct 4EE7
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=accessory && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=audio_source && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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 02:39:28 +02:00
|
|
|
on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=0
|
2012-04-04 20:26:59 +02: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
|
2016-08-01 23:45:18 +02:00
|
|
|
on boot && property:persist.sys.usb.config=*
|
2012-04-04 20:26:59 +02:00
|
|
|
setprop sys.usb.config ${persist.sys.usb.config}
|
2015-08-12 18:36:00 +02: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-03 22:50:27 +02:00
|
|
|
write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
|
2015-08-12 18:36:00 +02:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.data_role}
|
|
|
|
|
|
|
|
on property:sys.usb.typec.data_role=host
|
2015-09-03 22:50:27 +02:00
|
|
|
write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data_role}
|
2015-08-12 18:36:00 +02: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-03 22:50:27 +02:00
|
|
|
write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
|
2015-08-12 18:36:00 +02:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.power_role}
|
|
|
|
|
|
|
|
on property:sys.usb.typec.power_role=sink
|
2015-09-03 22:50:27 +02:00
|
|
|
write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power_role}
|
2015-08-12 18:36:00 +02:00
|
|
|
setprop sys.usb.typec.state ${sys.usb.typec.power_role}
|
2019-12-10 20:16:15 +01:00
|
|
|
|
|
|
|
on userspace-reboot-requested
|
|
|
|
setprop sys.usb.config ""
|
|
|
|
setprop sys.usb.configfs ""
|
|
|
|
setprop sys.usb.state ""
|