1 2 on init 3 4 sysclktz 0 5 6 loglevel 3 7 8 # setup the global environment 9 export PATH /sbin:/system/sbin:/system/bin:/system/xbin 10 export LD_LIBRARY_PATH /system/lib 11 export ANDROID_BOOTLOGO 1 12 export ANDROID_ROOT /system 13 export ANDROID_ASSETS /system/app 14 export ANDROID_DATA /data 15 export EXTERNAL_STORAGE /mnt/sdcard 16 export ASEC_MOUNTPOINT /mnt/asec 17 export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar 18 19 # Backward compatibility 20 symlink /system/etc /etc 21 symlink /sys/kernel/debug /d 22 23 # create mountpoints 24 mkdir /mnt 0775 root system 25 mkdir /mnt/sdcard 0000 system system 26 27 # Create cgroup mount point for cpu accounting 28 mkdir /acct 29 mount cgroup none /acct cpuacct 30 mkdir /acct/uid 31 32 # Backwards Compat - XXX: Going away in G* 33 symlink /mnt/sdcard /sdcard 34 35 mkdir /system 36 mkdir /data 0771 system system 37 mkdir /cache 0770 system cache 38 mkdir /config 0500 root root 39 40 # Directory for putting things only root should see. 41 mkdir /mnt/secure 0700 root root 42 43 # Directory for staging bindmounts 44 mkdir /mnt/secure/staging 0700 root root 45 46 # Directory-target for where the secure container 47 # imagefile directory will be bind-mounted 48 mkdir /mnt/secure/asec 0700 root root 49 50 # Secure container public mount points. 51 mkdir /mnt/asec 0700 root system 52 mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000 53 54 mount rootfs rootfs / ro remount 55 56 write /proc/sys/kernel/panic_on_oops 1 57 write /proc/sys/kernel/hung_task_timeout_secs 0 58 write /proc/cpu/alignment 4 59 write /proc/sys/kernel/sched_latency_ns 10000000 60 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 61 write /proc/sys/kernel/sched_compat_yield 1 62 write /proc/sys/kernel/sched_child_runs_first 0 63 64 # Create cgroup mount points for process groups 65 mkdir /dev/cpuctl 66 mount cgroup none /dev/cpuctl cpu 67 chown system system /dev/cpuctl 68 chown system system /dev/cpuctl/tasks 69 chmod 0777 /dev/cpuctl/tasks 70 write /dev/cpuctl/cpu.shares 1024 71 72 mkdir /dev/cpuctl/fg_boost 73 chown system system /dev/cpuctl/fg_boost/tasks 74 chmod 0777 /dev/cpuctl/fg_boost/tasks 75 write /dev/cpuctl/fg_boost/cpu.shares 1024 76 77 mkdir /dev/cpuctl/bg_non_interactive 78 chown system system /dev/cpuctl/bg_non_interactive/tasks 79 chmod 0777 /dev/cpuctl/bg_non_interactive/tasks 80 # 5.0 % 81 write /dev/cpuctl/bg_non_interactive/cpu.shares 52 82 83 # mount mtd partitions 84 # Mount /system rw first to give the filesystem a chance to save a checkpoint 85 mount yaffs2 mtd@system /system 86 mount yaffs2 mtd@system /system ro remount 87 88 # We chown/chmod /data again so because mount is run as root + defaults 89 mount yaffs2 mtd@userdata /data nosuid nodev 90 chown system system /data 91 chmod 0771 /data 92 93 # Create dump dir and collect dumps. 94 # Do this before we mount cache so eventually we can use cache for 95 # storing dumps on platforms which do not have a dedicated dump partition. 96 97 mkdir /data/dontpanic 98 chown root log /data/dontpanic 99 chmod 0750 /data/dontpanic 100 101 # Collect apanic data, free resources and re-arm trigger 102 copy /proc/apanic_console /data/dontpanic/apanic_console 103 chown root log /data/dontpanic/apanic_console 104 chmod 0640 /data/dontpanic/apanic_console 105 106 copy /proc/apanic_threads /data/dontpanic/apanic_threads 107 chown root log /data/dontpanic/apanic_threads 108 chmod 0640 /data/dontpanic/apanic_threads 109 110 write /proc/apanic_console 1 111 112 # Same reason as /data above 113 mount yaffs2 mtd@cache /cache nosuid nodev 114 chown system cache /cache 115 chmod 0770 /cache 116 117 # This may have been created by the recovery system with odd permissions 118 chown system cache /cache/recovery 119 chmod 0770 /cache/recovery 120 121 #change permissions on vmallocinfo so we can grab it from bugreports 122 chown root log /proc/vmallocinfo 123 chmod 0440 /proc/vmallocinfo 124 125 #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks 126 chown root system /proc/kmsg 127 chmod 0440 /proc/kmsg 128 chown root system /proc/sysrq-trigger 129 chmod 0220 /proc/sysrq-trigger 130 131 # create basic filesystem structure 132 mkdir /data/misc 01771 system misc 133 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth 134 mkdir /data/misc/bluetooth 0770 system system 135 mkdir /data/misc/keystore 0700 keystore keystore 136 mkdir /data/misc/vpn 0770 system system 137 mkdir /data/misc/systemkeys 0700 system system 138 mkdir /data/misc/vpn/profiles 0770 system system 139 # give system access to wpa_supplicant.conf for backup and restore 140 mkdir /data/misc/wifi 0770 wifi wifi 141 chmod 0770 /data/misc/wifi 142 chmod 0660 /data/misc/wifi/wpa_supplicant.conf 143 mkdir /data/local 0771 shell shell 144 mkdir /data/local/tmp 0771 shell shell 145 mkdir /data/data 0771 system system 146 mkdir /data/app-private 0771 system system 147 mkdir /data/app 0771 system system 148 mkdir /data/property 0700 root root 149 150 # create dalvik-cache and double-check the perms 151 mkdir /data/dalvik-cache 0771 system system 152 chown system system /data/dalvik-cache 153 chmod 0771 /data/dalvik-cache 154 155 # create the lost+found directories, so as to enforce our permissions 156 mkdir /data/lost+found 0770 157 mkdir /cache/lost+found 0770 158 159 # double check the perms, in case lost+found already exists, and set owner 160 chown root root /data/lost+found 161 chmod 0770 /data/lost+found 162 chown root root /cache/lost+found 163 chmod 0770 /cache/lost+found 164 165 on boot 166 # basic network init 167 ifup lo 168 hostname localhost 169 domainname localdomain 170 171 # set RLIMIT_NICE to allow priorities from 19 to -20 172 setrlimit 13 40 40 173 174 # Define the oom_adj values for the classes of processes that can be 175 # killed by the kernel. These are used in ActivityManagerService. 176 setprop ro.FOREGROUND_APP_ADJ 0 177 setprop ro.VISIBLE_APP_ADJ 1 178 setprop ro.SECONDARY_SERVER_ADJ 2 179 setprop ro.BACKUP_APP_ADJ 2 180 setprop ro.HOME_APP_ADJ 4 181 setprop ro.HIDDEN_APP_MIN_ADJ 7 182 setprop ro.CONTENT_PROVIDER_ADJ 14 183 setprop ro.EMPTY_APP_ADJ 15 184 185 # Define the memory thresholds at which the above process classes will 186 # be killed. These numbers are in pages (4k). 187 setprop ro.FOREGROUND_APP_MEM 1536 188 setprop ro.VISIBLE_APP_MEM 2048 189 setprop ro.SECONDARY_SERVER_MEM 4096 190 setprop ro.BACKUP_APP_MEM 4096 191 setprop ro.HOME_APP_MEM 4096 192 setprop ro.HIDDEN_APP_MEM 5120 193 setprop ro.CONTENT_PROVIDER_MEM 5632 194 setprop ro.EMPTY_APP_MEM 6144 195 196 # Write value must be consistent with the above properties. 197 # Note that the driver only supports 6 slots, so we have HOME_APP at the 198 # same memory level as services. 199 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 200 201 write /proc/sys/vm/overcommit_memory 1 202 write /proc/sys/vm/min_free_order_shift 4 203 write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144 204 205 # Set init its forked children's oom_adj. 206 write /proc/1/oom_adj -16 207 208 # Tweak background writeout 209 write /proc/sys/vm/dirty_expire_centisecs 200 210 write /proc/sys/vm/dirty_background_ratio 5 211 212 # Permissions for System Server and daemons. 213 chown radio system /sys/android_power/state 214 chown radio system /sys/android_power/request_state 215 chown radio system /sys/android_power/acquire_full_wake_lock 216 chown radio system /sys/android_power/acquire_partial_wake_lock 217 chown radio system /sys/android_power/release_wake_lock 218 chown radio system /sys/power/state 219 chown radio system /sys/power/wake_lock 220 chown radio system /sys/power/wake_unlock 221 chmod 0660 /sys/power/state 222 chmod 0660 /sys/power/wake_lock 223 chmod 0660 /sys/power/wake_unlock 224 chown system system /sys/class/timed_output/vibrator/enable 225 chown system system /sys/class/leds/keyboard-backlight/brightness 226 chown system system /sys/class/leds/lcd-backlight/brightness 227 chown system system /sys/class/leds/button-backlight/brightness 228 chown system system /sys/class/leds/jogball-backlight/brightness 229 chown system system /sys/class/leds/red/brightness 230 chown system system /sys/class/leds/green/brightness 231 chown system system /sys/class/leds/blue/brightness 232 chown system system /sys/class/leds/red/device/grpfreq 233 chown system system /sys/class/leds/red/device/grppwm 234 chown system system /sys/class/leds/red/device/blink 235 chown system system /sys/class/leds/red/brightness 236 chown system system /sys/class/leds/green/brightness 237 chown system system /sys/class/leds/blue/brightness 238 chown system system /sys/class/leds/red/device/grpfreq 239 chown system system /sys/class/leds/red/device/grppwm 240 chown system system /sys/class/leds/red/device/blink 241 chown system system /sys/class/timed_output/vibrator/enable 242 chown system system /sys/module/sco/parameters/disable_esco 243 chown system system /sys/kernel/ipv4/tcp_wmem_min 244 chown system system /sys/kernel/ipv4/tcp_wmem_def 245 chown system system /sys/kernel/ipv4/tcp_wmem_max 246 chown system system /sys/kernel/ipv4/tcp_rmem_min 247 chown system system /sys/kernel/ipv4/tcp_rmem_def 248 chown system system /sys/kernel/ipv4/tcp_rmem_max 249 chown root radio /proc/cmdline 250 251 # Define TCP buffer sizes for various networks 252 # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, 253 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 254 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 255 setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 256 setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 257 setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 258 259 class_start default 260 261 ## Daemon processes to be run by init. 262 ## 263 service console /system/bin/sh 264 console 265 266 # adbd is controlled by the persist.service.adb.enable system property 267 service adbd /sbin/adbd 268 disabled 269 270 # adbd on at boot in emulator 271 on property:ro.kernel.qemu=1 272 start adbd 273 274 on property:persist.service.adb.enable=1 275 start adbd 276 277 on property:persist.service.adb.enable=0 278 stop adbd 279 280 service servicemanager /system/bin/servicemanager 281 user system 282 critical 283 onrestart restart zygote 284 onrestart restart media 285 286 service vold /system/bin/vold 287 socket vold stream 0660 root mount 288 ioprio be 2 289 290 service netd /system/bin/netd 291 socket netd stream 0660 root system 292 293 service debuggerd /system/bin/debuggerd 294 295 service ril-daemon /system/bin/rild 296 socket rild stream 660 root radio 297 socket rild-debug stream 660 radio system 298 user root 299 group radio cache inet misc audio 300 301 service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server 302 socket zygote stream 666 303 onrestart write /sys/android_power/request_state wake 304 onrestart write /sys/power/state on 305 onrestart restart media 306 307 service media /system/bin/mediaserver 308 user media 309 group system audio camera graphics inet net_bt net_bt_admin net_raw 310 ioprio rt 4 311 312 service bootanim /system/bin/bootanimation 313 user graphics 314 group graphics 315 disabled 316 oneshot 317 318 service dbus /system/bin/dbus-daemon --system --nofork 319 socket dbus stream 660 bluetooth bluetooth 320 user bluetooth 321 group bluetooth net_bt_admin 322 323 service bluetoothd /system/bin/bluetoothd -n 324 socket bluetooth stream 660 bluetooth bluetooth 325 socket dbus_bluetooth stream 660 bluetooth bluetooth 326 # init.rc does not yet support applying capabilities, so run as root and 327 # let bluetoothd drop uid to bluetooth with the right linux capabilities 328 group bluetooth net_bt_admin misc 329 disabled 330 331 service hfag /system/bin/sdptool add --channel=10 HFAG 332 user bluetooth 333 group bluetooth net_bt_admin 334 disabled 335 oneshot 336 337 service hsag /system/bin/sdptool add --channel=11 HSAG 338 user bluetooth 339 group bluetooth net_bt_admin 340 disabled 341 oneshot 342 343 service opush /system/bin/sdptool add --channel=12 OPUSH 344 user bluetooth 345 group bluetooth net_bt_admin 346 disabled 347 oneshot 348 349 service pbap /system/bin/sdptool add --channel=19 PBAP 350 user bluetooth 351 group bluetooth net_bt_admin 352 disabled 353 oneshot 354 355 service installd /system/bin/installd 356 socket installd stream 600 system system 357 358 service flash_recovery /system/etc/install-recovery.sh 359 oneshot 360 361 service racoon /system/bin/racoon 362 socket racoon stream 600 system system 363 # racoon will setuid to vpn after getting necessary resources. 364 group net_admin 365 disabled 366 oneshot 367 368 service mtpd /system/bin/mtpd 369 socket mtpd stream 600 system system 370 user vpn 371 group vpn net_admin net_raw 372 disabled 373 oneshot 374 375 service keystore /system/bin/keystore /data/misc/keystore 376 user keystore 377 group keystore 378 socket keystore stream 666 379 380 service dumpstate /system/bin/dumpstate -s 381 socket dumpstate stream 0660 shell log 382 disabled 383 oneshot 384