blob: a4dd421608b1faed85b79fbb8a31b5a4f3a88a51 [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
Alessandro Astonede4cbe72019-09-06 12:36:55 +020026 rmdir /sbin
27 symlink /system/bin /sbin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080028
29 mkdir /sdcard
30 mkdir /system
31 mkdir /data
32 mkdir /cache
Doug Zongker075ad802014-06-26 15:35:51 -070033 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090034 mkdir /mnt/system
Doug Zongker075ef322014-01-14 09:50:35 -080035 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080036
Doug Zongker703ed152012-03-19 15:52:03 -070037 chown root shell /tmp
38 chmod 0775 /tmp
39
Tom Marshall292bd232019-01-04 14:37:31 -080040 mkdir /storage 0050 root sdcard_r
41 mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
42
43 mkdir /mnt 0775 root system
44
45 # See storage config details at http://source.android.com/tech/storage/
46 mkdir /mnt/shell 0700 shell shell
47
48 # Directory for staging bindmounts
49 mkdir /mnt/staging 0700 root root
50
Colin Cross22bcf972014-06-24 13:43:39 -070051 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080052 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070053
Yifan Hongcb22b132021-11-12 20:27:15 -080054 # Mount binderfs
55 mkdir /dev/binderfs
56 mount binder binder /dev/binderfs stats=global
57 chmod 0755 /dev/binderfs
58
59 symlink /dev/binderfs/binder /dev/binder
60 chmod 0666 /dev/binderfs/binder
61
Yifan Hong87980992021-11-12 20:04:14 -080062 # Start essential services
63 start servicemanager
64
Vojtech Bocekdb767792015-03-08 16:32:41 +010065 # pstore/ramoops previous console log
66 mount pstore pstore /sys/fs/pstore
67
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080068on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080069 ifup lo
70 hostname localhost
71 domainname localdomain
72
73 class_start default
Yifan Hong0fa17072021-11-13 01:34:16 -080074 class_start hal
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080075
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070076on firmware_mounts_complete
77 rm /dev/.booting
78
Riley Andrewse739d7e2014-06-24 16:29:16 -070079# Mount filesystems and start core system services.
80on late-init
81 trigger early-fs
82 trigger fs
83 trigger post-fs
84 trigger post-fs-data
85
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070086 # Remove a file to wake up anything waiting for firmware
87 trigger firmware_mounts_complete
88
Riley Andrewse739d7e2014-06-24 16:29:16 -070089 trigger early-boot
90 trigger boot
91
Tom Cherryb2fd1682018-07-24 15:58:29 -070092service ueventd /system/bin/ueventd
Colin Crossdd6a0412010-05-14 13:42:20 -070093 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -050094 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080095
Aaron Kling36c74892022-11-09 17:30:51 -060096service console /system/bin/sh
97 class core
98 console
99 disabled
100 user shell
101 group shell log readproc
102 seclabel u:r:shell:s0
103 setenv HOSTNAME console
104
105on init && property:ro.debuggable=1
106 start console
107
Tao Baoa89c21c2018-09-11 14:50:02 -0700108service charger /system/bin/charger
Todd Poynor2f2c9882013-06-04 13:11:44 -0700109 critical
Sandeep Patilc4b381c2016-11-01 08:49:51 -0700110 seclabel u:r:charger:s0
Todd Poynor2f2c9882013-06-04 13:11:44 -0700111
Hridya Valsarajucfb3c922018-07-26 13:04:06 -0700112service recovery /system/bin/recovery
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700113 socket recovery stream 422 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500114 seclabel u:r:recovery:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800115
Jiyong Park8b7af4c2018-06-01 11:58:54 +0900116service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -0700117 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -0700118 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500119 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800120
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700121service fastbootd /system/bin/fastbootd
122 disabled
123 group system
124 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800125
Mike Lockwood718a2f72011-06-29 10:22:04 -0400126# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -0700127on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700128 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700129
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700130on fs && property:sys.usb.configfs=1
131 mount configfs none /config
132 mkdir /config/usb_gadget/g1 0770 shell shell
133 write /config/usb_gadget/g1/idVendor 0x18D1
134 mkdir /config/usb_gadget/g1/strings/0x409 0770
135 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
136 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
137 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
138 mkdir /config/usb_gadget/g1/functions/ffs.adb
139 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
140 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
141 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
142
143on fs && property:sys.usb.configfs=0
144 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
145 write /sys/class/android_usb/android0/idVendor 18D1
146 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
147 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
148 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
149
150on fs
151 mkdir /dev/usb-ffs 0775 shell shell
152 mkdir /dev/usb-ffs/adb 0770 shell shell
153 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
154 mkdir /dev/usb-ffs/fastboot 0770 system system
155 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
156
157on property:sys.usb.config=adb
158 start adbd
159
160on property:sys.usb.config=fastboot
161 start fastbootd
162
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700163on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700164 stop adbd
Dmytro Prokopchukdf354052019-11-13 13:30:17 +0200165 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700166 write /sys/class/android_usb/android0/enable 0
167 setprop sys.usb.state ${sys.usb.config}
168
169on property:sys.usb.config=adb && property:sys.usb.configfs=0
170 write /sys/class/android_usb/android0/idProduct D001
171 write /sys/class/android_usb/android0/functions adb
Doug Zongkerfb04b872011-06-23 15:30:34 -0700172 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700173 setprop sys.usb.state ${sys.usb.config}
174
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700175on property:sys.usb.config=sideload && property:sys.usb.configfs=0
176 write /sys/class/android_usb/android0/idProduct D001
177 write /sys/class/android_usb/android0/functions adb
178 write /sys/class/android_usb/android0/enable 1
179 setprop sys.usb.state ${sys.usb.config}
180
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700181on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
182 write /sys/class/android_usb/android0/idProduct 4EE0
183 write /sys/class/android_usb/android0/functions fastboot
184 write /sys/class/android_usb/android0/enable 1
185 setprop sys.usb.state ${sys.usb.config}
186
187# Configfs triggers
188on property:sys.usb.config=none && property:sys.usb.configfs=1
189 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700190 stop adbd
191 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700192 setprop sys.usb.ffs.ready 0
193 rm /config/usb_gadget/g1/configs/b.1/f1
194 setprop sys.usb.state ${sys.usb.config}
195
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700196on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
197 write /config/usb_gadget/g1/idProduct 0xD001
198 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
199 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
200 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
201 setprop sys.usb.state ${sys.usb.config}
202
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700203on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
204 write /config/usb_gadget/g1/idProduct 0xD001
205 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
206 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
207 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
208 setprop sys.usb.state ${sys.usb.config}
209
210on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
211 write /config/usb_gadget/g1/idProduct 0x4EE0
212 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
213 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
214 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
215 setprop sys.usb.state ${sys.usb.config}