blob: c7ff2b2b968ace6e89d581ca37498726da9d744e [file] [log] [blame]
Colin Crossf510f062012-08-08 13:06:26 -07001import /init.recovery.${ro.hardware}.rc
2
Colin Crossdd6a0412010-05-14 13:42:20 -07003on early-init
Alex Deymo6bcc8af2016-03-02 14:21:02 -08004 # Set the security context of /postinstall if present.
5 restorecon /postinstall
6
Kiyoung Kimea2b6832019-12-17 15:05:54 +09007 # Copy prebuilt ld.config.txt into linkerconfig directory
8 copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt
Kiyoung Kim3a88a172019-12-09 19:27:57 +09009 chmod 444 /linkerconfig/ld.config.txt
10
Colin Crossdd6a0412010-05-14 13:42:20 -070011 start ueventd
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080012
Hridya Valsaraju20c81b32018-07-27 22:09:12 -070013 setprop sys.usb.configfs 0
14
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080015on init
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080016 export ANDROID_ROOT /system
17 export ANDROID_DATA /data
18 export EXTERNAL_STORAGE /sdcard
19
Elliott Hughesa4495b52018-08-23 08:31:59 -070020 symlink /proc/self/fd/0 /dev/stdin
21 symlink /proc/self/fd/1 /dev/stdout
22 symlink /proc/self/fd/2 /dev/stderr
23
Elliott Hughes4dca6f12017-12-06 08:41:50 -080024 symlink /system/bin /bin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080025 symlink /system/etc /etc
26
27 mkdir /sdcard
28 mkdir /system
29 mkdir /data
30 mkdir /cache
Doug Zongker075ad802014-06-26 15:35:51 -070031 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090032 mkdir /mnt/system
Doug Zongker075ef322014-01-14 09:50:35 -080033 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080034
Doug Zongker703ed152012-03-19 15:52:03 -070035 chown root shell /tmp
36 chmod 0775 /tmp
37
Colin Cross22bcf972014-06-24 13:43:39 -070038 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080039 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070040
Yifan Hongcb22b132021-11-12 20:27:15 -080041 # Mount binderfs
42 mkdir /dev/binderfs
43 mount binder binder /dev/binderfs stats=global
44 chmod 0755 /dev/binderfs
45
46 symlink /dev/binderfs/binder /dev/binder
47 chmod 0666 /dev/binderfs/binder
48
Yifan Hong87980992021-11-12 20:04:14 -080049 # Start essential services
50 start servicemanager
51
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080052on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080053 ifup lo
54 hostname localhost
55 domainname localdomain
56
57 class_start default
Yifan Hong0fa17072021-11-13 01:34:16 -080058 class_start hal
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080059
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070060on firmware_mounts_complete
61 rm /dev/.booting
62
Riley Andrewse739d7e2014-06-24 16:29:16 -070063# Mount filesystems and start core system services.
64on late-init
65 trigger early-fs
66 trigger fs
67 trigger post-fs
68 trigger post-fs-data
69
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070070 # Remove a file to wake up anything waiting for firmware
71 trigger firmware_mounts_complete
72
Riley Andrewse739d7e2014-06-24 16:29:16 -070073 trigger early-boot
74 trigger boot
75
Tom Cherryb2fd1682018-07-24 15:58:29 -070076service ueventd /system/bin/ueventd
Colin Crossdd6a0412010-05-14 13:42:20 -070077 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -050078 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080079
Tao Baoa89c21c2018-09-11 14:50:02 -070080service charger /system/bin/charger
Todd Poynor2f2c9882013-06-04 13:11:44 -070081 critical
Sandeep Patilc4b381c2016-11-01 08:49:51 -070082 seclabel u:r:charger:s0
Todd Poynor2f2c9882013-06-04 13:11:44 -070083
Hridya Valsarajucfb3c922018-07-26 13:04:06 -070084service recovery /system/bin/recovery
Hridya Valsaraju20c81b32018-07-27 22:09:12 -070085 socket recovery stream 422 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -050086 seclabel u:r:recovery:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080087
Jiyong Park8b7af4c2018-06-01 11:58:54 +090088service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -070089 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -070090 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -050091 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080092
Hridya Valsaraju20c81b32018-07-27 22:09:12 -070093service fastbootd /system/bin/fastbootd
94 disabled
95 group system
96 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080097
Mike Lockwood718a2f72011-06-29 10:22:04 -040098# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -070099on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700100 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700101
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700102on fs && property:sys.usb.configfs=1
103 mount configfs none /config
104 mkdir /config/usb_gadget/g1 0770 shell shell
Josh Gaoc40208c2022-08-17 12:57:17 -0700105 write /config/usb_gadget/g1/idVendor 0x${ro.recovery.usb.vid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700106 mkdir /config/usb_gadget/g1/strings/0x409 0770
107 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
108 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
109 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
110 mkdir /config/usb_gadget/g1/functions/ffs.adb
111 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
112 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
Roy Luofe37b5e2023-04-05 08:51:26 +0000113 # Set current limit to 900mA (b/277022505)
114 write /config/usb_gadget/g1/configs/b.1/MaxPower 0x384
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700115 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
116
117on fs && property:sys.usb.configfs=0
118 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
Josh Gaoc40208c2022-08-17 12:57:17 -0700119 write /sys/class/android_usb/android0/idVendor ${ro.recovery.usb.vid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700120 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
121 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
122 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
123
124on fs
125 mkdir /dev/usb-ffs 0775 shell shell
126 mkdir /dev/usb-ffs/adb 0770 shell shell
127 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
128 mkdir /dev/usb-ffs/fastboot 0770 system system
129 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
130
131on property:sys.usb.config=adb
132 start adbd
133
134on property:sys.usb.config=fastboot
135 start fastbootd
136
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700137on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700138 stop adbd
Dmytro Prokopchukdf354052019-11-13 13:30:17 +0200139 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700140 write /sys/class/android_usb/android0/enable 0
141 setprop sys.usb.state ${sys.usb.config}
142
143on property:sys.usb.config=adb && property:sys.usb.configfs=0
Josh Gaoc40208c2022-08-17 12:57:17 -0700144 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700145 write /sys/class/android_usb/android0/functions adb
Doug Zongkerfb04b872011-06-23 15:30:34 -0700146 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700147 setprop sys.usb.state ${sys.usb.config}
148
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700149on property:sys.usb.config=sideload && property:sys.usb.configfs=0
Josh Gaoc40208c2022-08-17 12:57:17 -0700150 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid}
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700151 write /sys/class/android_usb/android0/functions adb
152 write /sys/class/android_usb/android0/enable 1
153 setprop sys.usb.state ${sys.usb.config}
154
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700155on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
Josh Gaoc40208c2022-08-17 12:57:17 -0700156 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.fastboot.pid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700157 write /sys/class/android_usb/android0/functions fastboot
158 write /sys/class/android_usb/android0/enable 1
159 setprop sys.usb.state ${sys.usb.config}
160
161# Configfs triggers
162on property:sys.usb.config=none && property:sys.usb.configfs=1
163 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700164 stop adbd
165 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700166 setprop sys.usb.ffs.ready 0
167 rm /config/usb_gadget/g1/configs/b.1/f1
168 setprop sys.usb.state ${sys.usb.config}
169
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700170on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
Josh Gaoc40208c2022-08-17 12:57:17 -0700171 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid}
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700172 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
173 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
174 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
175 setprop sys.usb.state ${sys.usb.config}
176
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700177on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
Josh Gaoc40208c2022-08-17 12:57:17 -0700178 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700179 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
180 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
181 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
182 setprop sys.usb.state ${sys.usb.config}
183
184on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
Josh Gaoc40208c2022-08-17 12:57:17 -0700185 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.fastboot.pid}
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700186 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
187 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
188 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
189 setprop sys.usb.state ${sys.usb.config}