1import /init.recovery.${ro.hardware}.rc 2 3on early-init 4 # Set the security context of /postinstall if present. 5 restorecon /postinstall 6 7 # Copy prebuilt ld.config.txt into linkerconfig directory 8 copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt 9 chmod 444 /linkerconfig/ld.config.txt 10 11 start ueventd 12 13 setprop sys.usb.configfs 0 14 15on init 16 export ANDROID_ROOT /system 17 export ANDROID_DATA /data 18 export EXTERNAL_STORAGE /sdcard 19 20 symlink /proc/self/fd/0 /dev/stdin 21 symlink /proc/self/fd/1 /dev/stdout 22 symlink /proc/self/fd/2 /dev/stderr 23 24 symlink /system/bin /bin 25 symlink /system/etc /etc 26 27 mkdir /sdcard 28 mkdir /system 29 mkdir /data 30 mkdir /cache 31 mkdir /sideload 32 mkdir /mnt/system 33 mount tmpfs tmpfs /tmp 34 35 chown root shell /tmp 36 chmod 0775 /tmp 37 38 write /proc/sys/kernel/panic_on_oops 1 39 write /proc/sys/vm/max_map_count 1000000 40 41 # 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 49 # Start essential services 50 start servicemanager 51 52on boot 53 ifup lo 54 hostname localhost 55 domainname localdomain 56 57 class_start default 58 class_start hal 59 60on firmware_mounts_complete 61 rm /dev/.booting 62 63# 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 70 # Remove a file to wake up anything waiting for firmware 71 trigger firmware_mounts_complete 72 73 trigger early-boot 74 trigger boot 75 76service ueventd /system/bin/ueventd 77 critical 78 seclabel u:r:ueventd:s0 79 user root 80 81service charger /system/bin/charger 82 critical 83 seclabel u:r:charger:s0 84 user root 85 86service recovery /system/bin/recovery 87 socket recovery stream 422 system system 88 seclabel u:r:recovery:s0 89 user root 90 91service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery 92 disabled 93 socket adbd stream 660 system system 94 seclabel u:r:adbd:s0 95 user root 96 97service fastbootd /system/bin/fastbootd 98 disabled 99 group system 100 seclabel u:r:fastbootd:s0 101 user root 102 103# Restart adbd so it can run as root 104on property:service.adb.root=1 105 restart adbd 106 107on fs && property:sys.usb.configfs=1 108 mount configfs none /config 109 mkdir /config/usb_gadget/g1 0770 shell shell 110 write /config/usb_gadget/g1/idVendor 0x${ro.recovery.usb.vid} 111 mkdir /config/usb_gadget/g1/strings/0x409 0770 112 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} 113 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} 114 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} 115 mkdir /config/usb_gadget/g1/functions/ffs.adb 116 mkdir /config/usb_gadget/g1/functions/ffs.fastboot 117 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell 118 # Set current limit to 900mA (b/277022505) 119 write /config/usb_gadget/g1/configs/b.1/MaxPower 0x384 120 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell 121 122on fs && property:sys.usb.configfs=0 123 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot 124 write /sys/class/android_usb/android0/idVendor ${ro.recovery.usb.vid} 125 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} 126 write /sys/class/android_usb/android0/iProduct ${ro.product.model} 127 write /sys/class/android_usb/android0/iSerial ${ro.serialno} 128 129on fs 130 mkdir /dev/usb-ffs 0775 shell shell 131 mkdir /dev/usb-ffs/adb 0770 shell shell 132 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 133 mkdir /dev/usb-ffs/fastboot 0770 system system 134 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000 135 136on property:sys.usb.config=adb 137 start adbd 138 139on property:sys.usb.config=fastboot 140 start fastbootd 141 142on property:sys.usb.config=none && property:sys.usb.configfs=0 143 stop adbd 144 stop fastbootd 145 write /sys/class/android_usb/android0/enable 0 146 setprop sys.usb.state ${sys.usb.config} 147 148on property:sys.usb.config=adb && property:sys.usb.configfs=0 149 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid} 150 write /sys/class/android_usb/android0/functions adb 151 write /sys/class/android_usb/android0/enable 1 152 setprop sys.usb.state ${sys.usb.config} 153 154on property:sys.usb.config=sideload && property:sys.usb.configfs=0 155 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid} 156 write /sys/class/android_usb/android0/functions adb 157 write /sys/class/android_usb/android0/enable 1 158 setprop sys.usb.state ${sys.usb.config} 159 160on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 161 write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.fastboot.pid} 162 write /sys/class/android_usb/android0/functions fastboot 163 write /sys/class/android_usb/android0/enable 1 164 setprop sys.usb.state ${sys.usb.config} 165 166# Configfs triggers 167on property:sys.usb.config=none && property:sys.usb.configfs=1 168 write /config/usb_gadget/g1/UDC "none" 169 stop adbd 170 stop fastbootd 171 setprop sys.usb.ffs.ready 0 172 rm /config/usb_gadget/g1/configs/b.1/f1 173 setprop sys.usb.state ${sys.usb.config} 174 175on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 176 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid} 177 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" 178 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 179 write /config/usb_gadget/g1/UDC ${sys.usb.controller} 180 setprop sys.usb.state ${sys.usb.config} 181 182on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 183 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid} 184 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" 185 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 186 write /config/usb_gadget/g1/UDC ${sys.usb.controller} 187 setprop sys.usb.state ${sys.usb.config} 188 189on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 190 write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.fastboot.pid} 191 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" 192 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 193 write /config/usb_gadget/g1/UDC ${sys.usb.controller} 194 setprop sys.usb.state ${sys.usb.config} 195