Colin Cross | f510f06 | 2012-08-08 13:06:26 -0700 | [diff] [blame] | 1 | import /init.recovery.${ro.hardware}.rc |
| 2 | |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 3 | on early-init |
Alex Deymo | 6bcc8af | 2016-03-02 14:21:02 -0800 | [diff] [blame] | 4 | # Set the security context of /postinstall if present. |
| 5 | restorecon /postinstall |
| 6 | |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 7 | start ueventd |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 8 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 9 | setprop sys.usb.configfs 0 |
| 10 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 11 | on init |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 12 | export ANDROID_ROOT /system |
| 13 | export ANDROID_DATA /data |
| 14 | export EXTERNAL_STORAGE /sdcard |
| 15 | |
Elliott Hughes | a4495b5 | 2018-08-23 08:31:59 -0700 | [diff] [blame] | 16 | symlink /proc/self/fd/0 /dev/stdin |
| 17 | symlink /proc/self/fd/1 /dev/stdout |
| 18 | symlink /proc/self/fd/2 /dev/stderr |
| 19 | |
Elliott Hughes | 4dca6f1 | 2017-12-06 08:41:50 -0800 | [diff] [blame] | 20 | symlink /system/bin /bin |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 21 | symlink /system/etc /etc |
| 22 | |
Elliott Hughes | 48ebb07 | 2016-06-15 15:15:15 -0700 | [diff] [blame] | 23 | mount cgroup none /acct cpuacct |
| 24 | mkdir /acct/uid |
| 25 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 26 | mkdir /sdcard |
| 27 | mkdir /system |
| 28 | mkdir /data |
| 29 | mkdir /cache |
Doug Zongker | 075ad80 | 2014-06-26 15:35:51 -0700 | [diff] [blame] | 30 | mkdir /sideload |
Jiyong Park | 8b7af4c | 2018-06-01 11:58:54 +0900 | [diff] [blame] | 31 | mkdir /mnt/system |
Doug Zongker | 075ef32 | 2014-01-14 09:50:35 -0800 | [diff] [blame] | 32 | mount tmpfs tmpfs /tmp |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 33 | |
Doug Zongker | 703ed15 | 2012-03-19 15:52:03 -0700 | [diff] [blame] | 34 | chown root shell /tmp |
| 35 | chmod 0775 /tmp |
| 36 | |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 37 | write /proc/sys/kernel/panic_on_oops 1 |
Jesse Zhao | 5bf74b2 | 2015-01-08 15:59:23 -0800 | [diff] [blame] | 38 | write /proc/sys/vm/max_map_count 1000000 |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 39 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 40 | on boot |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 41 | ifup lo |
| 42 | hostname localhost |
| 43 | domainname localdomain |
| 44 | |
| 45 | class_start default |
| 46 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 47 | # Load properties from /system/ + /factory after fs mount. |
Paul Lawrence | 90c75b0 | 2015-07-06 10:44:33 -0700 | [diff] [blame] | 48 | on load_system_props_action |
| 49 | load_system_props |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 50 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 51 | on firmware_mounts_complete |
| 52 | rm /dev/.booting |
| 53 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 54 | # Mount filesystems and start core system services. |
| 55 | on late-init |
| 56 | trigger early-fs |
| 57 | trigger fs |
| 58 | trigger post-fs |
| 59 | trigger post-fs-data |
| 60 | |
| 61 | # Load properties from /system/ + /factory after fs mount. Place |
| 62 | # this in another action so that the load will be scheduled after the prior |
| 63 | # issued fs triggers have completed. |
Paul Lawrence | 90c75b0 | 2015-07-06 10:44:33 -0700 | [diff] [blame] | 64 | trigger load_system_props_action |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 65 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 66 | # Remove a file to wake up anything waiting for firmware |
| 67 | trigger firmware_mounts_complete |
| 68 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 69 | trigger early-boot |
| 70 | trigger boot |
| 71 | |
Tom Cherry | b2fd168 | 2018-07-24 15:58:29 -0700 | [diff] [blame] | 72 | service ueventd /system/bin/ueventd |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 73 | critical |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 74 | seclabel u:r:ueventd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 75 | |
Tao Bao | a89c21c | 2018-09-11 14:50:02 -0700 | [diff] [blame] | 76 | service charger /system/bin/charger |
Todd Poynor | 2f2c988 | 2013-06-04 13:11:44 -0700 | [diff] [blame] | 77 | critical |
Sandeep Patil | c4b381c | 2016-11-01 08:49:51 -0700 | [diff] [blame] | 78 | seclabel u:r:charger:s0 |
Todd Poynor | 2f2c988 | 2013-06-04 13:11:44 -0700 | [diff] [blame] | 79 | |
Hridya Valsaraju | cfb3c92 | 2018-07-26 13:04:06 -0700 | [diff] [blame] | 80 | service recovery /system/bin/recovery |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 81 | socket recovery stream 422 system system |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 82 | seclabel u:r:recovery:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 83 | |
Jiyong Park | 8b7af4c | 2018-06-01 11:58:54 +0900 | [diff] [blame] | 84 | service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery |
Kenny Root | ecc76ba | 2010-06-28 09:01:22 -0700 | [diff] [blame] | 85 | disabled |
Doug Zongker | cc2958f | 2013-09-11 13:24:32 -0700 | [diff] [blame] | 86 | socket adbd stream 660 system system |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 87 | seclabel u:r:adbd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 88 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 89 | service fastbootd /system/bin/fastbootd |
| 90 | disabled |
| 91 | group system |
| 92 | seclabel u:r:fastbootd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 93 | |
Mike Lockwood | 718a2f7 | 2011-06-29 10:22:04 -0400 | [diff] [blame] | 94 | # Restart adbd so it can run as root |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 95 | on property:service.adb.root=1 |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 96 | restart adbd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 97 | |
| 98 | # Always start adbd on userdebug and eng builds |
| 99 | on fs && property:ro.debuggable=1 |
| 100 | setprop sys.usb.config adb |
| 101 | |
Tianjie Xu | 7d5c341 | 2019-10-29 21:44:39 -0700 | [diff] [blame^] | 102 | # Also start adbd on user build with an unlocked bootloader |
| 103 | on fs && property:ro.debuggable=0 && androidboot.verifiedbootstate=orange |
| 104 | setprop sys.usb.config adb |
| 105 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 106 | on fs && property:sys.usb.configfs=1 |
| 107 | mount configfs none /config |
| 108 | mkdir /config/usb_gadget/g1 0770 shell shell |
| 109 | write /config/usb_gadget/g1/idVendor 0x18D1 |
| 110 | mkdir /config/usb_gadget/g1/strings/0x409 0770 |
| 111 | write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} |
| 112 | write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} |
| 113 | write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} |
| 114 | mkdir /config/usb_gadget/g1/functions/ffs.adb |
| 115 | mkdir /config/usb_gadget/g1/functions/ffs.fastboot |
| 116 | mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell |
| 117 | mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell |
| 118 | |
| 119 | on fs && property:sys.usb.configfs=0 |
| 120 | write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot |
| 121 | write /sys/class/android_usb/android0/idVendor 18D1 |
| 122 | write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} |
| 123 | write /sys/class/android_usb/android0/iProduct ${ro.product.model} |
| 124 | write /sys/class/android_usb/android0/iSerial ${ro.serialno} |
| 125 | |
| 126 | on fs |
| 127 | mkdir /dev/usb-ffs 0775 shell shell |
| 128 | mkdir /dev/usb-ffs/adb 0770 shell shell |
| 129 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 |
| 130 | mkdir /dev/usb-ffs/fastboot 0770 system system |
| 131 | mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000 |
| 132 | |
| 133 | on property:sys.usb.config=adb |
| 134 | start adbd |
| 135 | |
| 136 | on property:sys.usb.config=fastboot |
| 137 | start fastbootd |
| 138 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 139 | on property:sys.usb.config=none && property:sys.usb.configfs=0 |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 140 | stop adbd |
| 141 | stop fastboot |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 142 | write /sys/class/android_usb/android0/enable 0 |
| 143 | setprop sys.usb.state ${sys.usb.config} |
| 144 | |
| 145 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 |
| 146 | write /sys/class/android_usb/android0/idProduct D001 |
| 147 | write /sys/class/android_usb/android0/functions adb |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 148 | write /sys/class/android_usb/android0/enable 1 |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 149 | setprop sys.usb.state ${sys.usb.config} |
| 150 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 151 | on property:sys.usb.config=sideload && property:sys.usb.configfs=0 |
| 152 | write /sys/class/android_usb/android0/idProduct D001 |
| 153 | write /sys/class/android_usb/android0/functions adb |
| 154 | write /sys/class/android_usb/android0/enable 1 |
| 155 | setprop sys.usb.state ${sys.usb.config} |
| 156 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 157 | on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 |
| 158 | write /sys/class/android_usb/android0/idProduct 4EE0 |
| 159 | write /sys/class/android_usb/android0/functions fastboot |
| 160 | write /sys/class/android_usb/android0/enable 1 |
| 161 | setprop sys.usb.state ${sys.usb.config} |
| 162 | |
| 163 | # Configfs triggers |
| 164 | on property:sys.usb.config=none && property:sys.usb.configfs=1 |
| 165 | write /config/usb_gadget/g1/UDC "none" |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 166 | stop adbd |
| 167 | stop fastbootd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 168 | setprop sys.usb.ffs.ready 0 |
| 169 | rm /config/usb_gadget/g1/configs/b.1/f1 |
| 170 | setprop sys.usb.state ${sys.usb.config} |
| 171 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 172 | on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
| 173 | write /config/usb_gadget/g1/idProduct 0xD001 |
| 174 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" |
| 175 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 |
| 176 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 177 | setprop sys.usb.state ${sys.usb.config} |
| 178 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 179 | on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
| 180 | write /config/usb_gadget/g1/idProduct 0xD001 |
| 181 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" |
| 182 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 |
| 183 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 184 | setprop sys.usb.state ${sys.usb.config} |
| 185 | |
| 186 | on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
| 187 | write /config/usb_gadget/g1/idProduct 0x4EE0 |
| 188 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" |
| 189 | symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 |
| 190 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 191 | setprop sys.usb.state ${sys.usb.config} |