| 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 /sdcard |
| 16 |
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar |
| 17 |
|
| 18 |
# Backward compatibility |
| 19 |
symlink /system/etc /etc |
| 20 |
|
| 21 |
# create mountpoints and mount tmpfs on sqlite_stmt_journals |
| 22 |
mkdir /sdcard 0000 system system |
| 23 |
mkdir /system |
| 24 |
mkdir /data 0771 system system |
| 25 |
mkdir /cache 0770 system cache |
| 26 |
mkdir /sqlite_stmt_journals 01777 root root |
| 27 |
mount tmpfs tmpfs /sqlite_stmt_journals size=4m |
| 28 |
|
| 29 |
mount rootfs rootfs / ro remount |
| 30 |
|
| 31 |
write /proc/sys/kernel/panic_on_oops 1 |
| 32 |
write /proc/sys/kernel/hung_task_timeout_secs 0 |
| 33 |
write /proc/cpu/alignment 4 |
| 34 |
write /proc/sys/kernel/sched_latency_ns 10000000 |
| 35 |
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 |
| 36 |
write /proc/sys/kernel/sched_compat_yield 1 |
| 37 |
|
| 38 |
# Create cgroup mount points for process groups |
| 39 |
mkdir /dev/cpuctl |
| 40 |
mount cgroup none /dev/cpuctl cpu |
| 41 |
chown system system /dev/cpuctl |
| 42 |
chown system system /dev/cpuctl/tasks |
| 43 |
chmod 0777 /dev/cpuctl/tasks |
| 44 |
write /dev/cpuctl/cpu.shares 1024 |
| 45 |
|
| 46 |
mkdir /dev/cpuctl/fg_boost |
| 47 |
chown system system /dev/cpuctl/fg_boost/tasks |
| 48 |
chmod 0777 /dev/cpuctl/fg_boost/tasks |
| 49 |
write /dev/cpuctl/fg_boost/cpu.shares 1024 |
| 50 |
|
| 51 |
mkdir /dev/cpuctl/bg_non_interactive |
| 52 |
chown system system /dev/cpuctl/bg_non_interactive/tasks |
| 53 |
chmod 0777 /dev/cpuctl/bg_non_interactive/tasks |
| 54 |
# 5.0 % |
| 55 |
write /dev/cpuctl/bg_non_interactive/cpu.shares 52 |
| 56 |
|
| 57 |
# mount mtd partitions |
| 58 |
mount ext3 /dev/block/sda6 /system ro |
| 59 |
|
| 60 |
# We chown/chmod /data again so because mount is run as root + defaults |
| 61 |
mount ext3 /dev/block/sda8 /data nosuid nodev |
| 62 |
chown system system /data |
| 63 |
chmod 0771 /data |
| 64 |
|
| 65 |
# Same reason as /data above |
| 66 |
mount ext3 /dev/block/sda5 /cache nosuid nodev |
| 67 |
chown system cache /cache |
| 68 |
chmod 0770 /cache |
| 69 |
|
| 70 |
# This may have been created by the recovery system with odd permissions |
| 71 |
chown system system /cache/recovery |
| 72 |
chmod 0770 /cache/recovery |
| 73 |
|
| 74 |
# create basic filesystem structure |
| 75 |
mkdir /data/misc 01771 system misc |
| 76 |
mkdir /data/misc/hcid 0770 bluetooth bluetooth |
| 77 |
mkdir /data/misc/keystore 0770 keystore keystore |
| 78 |
mkdir /data/misc/vpn 0770 system system |
| 79 |
mkdir /data/misc/vpn/profiles 0770 system system |
| 80 |
# give system access to wpa_supplicant.conf for backup and restore |
| 81 |
mkdir /data/misc/wifi 0770 wifi wifi |
| 82 |
chmod 0770 /data/misc/wifi |
| 83 |
chmod 0660 /data/misc/wifi/wpa_supplicant.conf |
| 84 |
mkdir /data/local 0771 shell shell |
| 85 |
mkdir /data/local/tmp 0771 shell shell |
| 86 |
mkdir /data/data 0771 system system |
| 87 |
mkdir /data/app-private 0771 system system |
| 88 |
mkdir /data/app 0771 system system |
| 89 |
mkdir /data/property 0700 root root |
| 90 |
|
| 91 |
# create dalvik-cache and double-check the perms |
| 92 |
mkdir /data/dalvik-cache 0771 system system |
| 93 |
chown system system /data/dalvik-cache |
| 94 |
chmod 0771 /data/dalvik-cache |
| 95 |
|
| 96 |
# create the lost+found directories, so as to enforce our permissions |
| 97 |
mkdir /data/lost+found 0770 |
| 98 |
mkdir /cache/lost+found 0770 |
| 99 |
|
| 100 |
# double check the perms, in case lost+found already exists, and set owner |
| 101 |
chown root root /data/lost+found |
| 102 |
chmod 0770 /data/lost+found |
| 103 |
chown root root /cache/lost+found |
| 104 |
chmod 0770 /cache/lost+found |
| 105 |
|
| 106 |
on boot |
| 107 |
# basic network init |
| 108 |
ifup lo |
| 109 |
hostname localhost |
| 110 |
domainname localdomain |
| 111 |
|
| 112 |
# set RLIMIT_NICE to allow priorities from 19 to -20 |
| 113 |
setrlimit 13 40 40 |
| 114 |
|
| 115 |
# Define the oom_adj values for the classes of processes that can be |
| 116 |
# killed by the kernel. These are used in ActivityManagerService. |
| 117 |
setprop ro.FOREGROUND_APP_ADJ 0 |
| 118 |
setprop ro.VISIBLE_APP_ADJ 1 |
| 119 |
setprop ro.SECONDARY_SERVER_ADJ 2 |
| 120 |
setprop ro.BACKUP_APP_ADJ 2 |
| 121 |
setprop ro.HOME_APP_ADJ 4 |
| 122 |
setprop ro.HIDDEN_APP_MIN_ADJ 7 |
| 123 |
setprop ro.CONTENT_PROVIDER_ADJ 14 |
| 124 |
setprop ro.EMPTY_APP_ADJ 15 |
| 125 |
|
| 126 |
# Define the memory thresholds at which the above process classes will |
| 127 |
# be killed. These numbers are in pages (4k). |
| 128 |
setprop ro.FOREGROUND_APP_MEM 1536 |
| 129 |
setprop ro.VISIBLE_APP_MEM 2048 |
| 130 |
setprop ro.SECONDARY_SERVER_MEM 4096 |
| 131 |
setprop ro.BACKUP_APP_MEM 4096 |
| 132 |
setprop ro.HOME_APP_MEM 4096 |
| 133 |
setprop ro.HIDDEN_APP_MEM 5120 |
| 134 |
setprop ro.CONTENT_PROVIDER_MEM 5632 |
| 135 |
setprop ro.EMPTY_APP_MEM 6144 |
| 136 |
|
| 137 |
# Write value must be consistent with the above properties. |
| 138 |
# Note that the driver only supports 6 slots, so we have HOME_APP at the |
| 139 |
# same memory level as services. |
| 140 |
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 |
| 141 |
|
| 142 |
write /proc/sys/vm/overcommit_memory 1 |
| 143 |
write /proc/sys/vm/min_free_order_shift 4 |
| 144 |
write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144 |
| 145 |
|
| 146 |
# Set init its forked children's oom_adj. |
| 147 |
write /proc/1/oom_adj -16 |
| 148 |
|
| 149 |
# Permissions for System Server and daemons. |
| 150 |
chown radio system /sys/android_power/state |
| 151 |
chown radio system /sys/android_power/request_state |
| 152 |
chown radio system /sys/android_power/acquire_full_wake_lock |
| 153 |
chown radio system /sys/android_power/acquire_partial_wake_lock |
| 154 |
chown radio system /sys/android_power/release_wake_lock |
| 155 |
chown radio system /sys/power/state |
| 156 |
chown radio system /sys/power/wake_lock |
| 157 |
chown radio system /sys/power/wake_unlock |
| 158 |
chmod 0660 /sys/power/state |
| 159 |
chmod 0660 /sys/power/wake_lock |
| 160 |
chmod 0660 /sys/power/wake_unlock |
| 161 |
chown system system /sys/class/timed_output/vibrator/enable |
| 162 |
chown system system /sys/class/leds/keyboard-backlight/brightness |
| 163 |
chown system system /sys/class/leds/lcd-backlight/brightness |
| 164 |
chown system system /sys/class/leds/button-backlight/brightness |
| 165 |
chown system system /sys/class/leds/jogball-backlight/brightness |
| 166 |
chown system system /sys/class/leds/red/brightness |
| 167 |
chown system system /sys/class/leds/green/brightness |
| 168 |
chown system system /sys/class/leds/blue/brightness |
| 169 |
chown system system /sys/class/leds/red/device/grpfreq |
| 170 |
chown system system /sys/class/leds/red/device/grppwm |
| 171 |
chown system system /sys/class/leds/red/device/blink |
| 172 |
chown system system /sys/class/leds/red/brightness |
| 173 |
chown system system /sys/class/leds/green/brightness |
| 174 |
chown system system /sys/class/leds/blue/brightness |
| 175 |
chown system system /sys/class/leds/red/device/grpfreq |
| 176 |
chown system system /sys/class/leds/red/device/grppwm |
| 177 |
chown system system /sys/class/leds/red/device/blink |
| 178 |
chown system system /sys/class/timed_output/vibrator/enable |
| 179 |
chown system system /sys/module/sco/parameters/disable_esco |
| 180 |
chown system system /sys/kernel/ipv4/tcp_wmem_min |
| 181 |
chown system system /sys/kernel/ipv4/tcp_wmem_def |
| 182 |
chown system system /sys/kernel/ipv4/tcp_wmem_max |
| 183 |
chown system system /sys/kernel/ipv4/tcp_rmem_min |
| 184 |
chown system system /sys/kernel/ipv4/tcp_rmem_def |
| 185 |
chown system system /sys/kernel/ipv4/tcp_rmem_max |
| 186 |
chown root radio /proc/cmdline |
| 187 |
|
| 188 |
# Define TCP buffer sizes for various networks |
| 189 |
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, |
| 190 |
setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 |
| 191 |
setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 |
| 192 |
setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 |
| 193 |
setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 |
| 194 |
setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 |
| 195 |
|
| 196 |
class_start default |
| 197 |
|
| 198 |
## Daemon processes to be run by init. |
| 199 |
## |
| 200 |
service console /system/bin/sh |
| 201 |
console |
| 202 |
|
| 203 |
# adbd is controlled by the persist.service.adb.enable system property |
| 204 |
service adbd /sbin/adbd |
| 205 |
disabled |
| 206 |
|
| 207 |
# adbd on at boot in emulator |
| 208 |
on property:ro.kernel.qemu=1 |
| 209 |
start adbd |
| 210 |
|
| 211 |
on property:persist.service.adb.enable=1 |
| 212 |
start adbd |
| 213 |
|
| 214 |
on property:persist.service.adb.enable=0 |
| 215 |
stop adbd |
| 216 |
|
| 217 |
service servicemanager /system/bin/servicemanager |
| 218 |
user system |
| 219 |
critical |
| 220 |
onrestart restart zygote |
| 221 |
onrestart restart media |
| 222 |
|
| 223 |
service vold /system/bin/vold |
| 224 |
socket vold stream 0660 root mount |
| 225 |
|
| 226 |
service nexus /system/bin/nexus |
| 227 |
socket nexus stream 0660 root system |
| 228 |
disabled |
| 229 |
|
| 230 |
#service mountd /system/bin/mountd |
| 231 |
# socket mountd stream 0660 root mount |
| 232 |
|
| 233 |
service debuggerd /system/bin/debuggerd |
| 234 |
|
| 235 |
service ril-daemon /system/bin/rild |
| 236 |
socket rild stream 660 root radio |
| 237 |
socket rild-debug stream 660 radio system |
| 238 |
user root |
| 239 |
group radio cache inet misc |
| 240 |
|
| 241 |
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server |
| 242 |
socket zygote stream 666 |
| 243 |
onrestart write /sys/android_power/request_state wake |
| 244 |
onrestart write /sys/power/state on |
| 245 |
disabled |
| 246 |
|
| 247 |
service media /system/bin/mediaserver |
| 248 |
user media |
| 249 |
group system audio camera graphics inet net_bt net_bt_admin |
| 250 |
|
| 251 |
service bootsound /system/bin/playmp3 |
| 252 |
user media |
| 253 |
group audio |
| 254 |
oneshot |
| 255 |
|
| 256 |
service bootanim /system/bin/bootanimation |
| 257 |
user graphics |
| 258 |
group graphics |
| 259 |
disabled |
| 260 |
oneshot |
| 261 |
|
| 262 |
service dbus /system/bin/dbus-daemon --system --nofork |
| 263 |
socket dbus stream 660 bluetooth bluetooth |
| 264 |
user bluetooth |
| 265 |
group bluetooth net_bt_admin |
| 266 |
|
| 267 |
service hcid /system/bin/hcid -s -n -f /etc/bluez/hcid.conf |
| 268 |
socket bluetooth stream 660 bluetooth bluetooth |
| 269 |
socket dbus_bluetooth stream 660 bluetooth bluetooth |
| 270 |
# init.rc does not yet support applying capabilities, so run as root and |
| 271 |
# let hcid drop uid to bluetooth with the right linux capabilities |
| 272 |
group bluetooth net_bt_admin misc |
| 273 |
disabled |
| 274 |
|
| 275 |
service hfag /system/bin/sdptool add --channel=10 HFAG |
| 276 |
user bluetooth |
| 277 |
group bluetooth net_bt_admin |
| 278 |
disabled |
| 279 |
oneshot |
| 280 |
|
| 281 |
service hsag /system/bin/sdptool add --channel=11 HSAG |
| 282 |
user bluetooth |
| 283 |
group bluetooth net_bt_admin |
| 284 |
disabled |
| 285 |
oneshot |
| 286 |
|
| 287 |
service installd /system/bin/installd |
| 288 |
socket installd stream 600 system system |
| 289 |
|
| 290 |
service flash_recovery /system/etc/install-recovery.sh |
| 291 |
oneshot |
| 292 |
|
| 293 |
service racoon /system/bin/racoon |
| 294 |
socket racoon stream 600 system system |
| 295 |
# racoon will setuid to vpn after getting necessary resources. |
| 296 |
group net_admin keystore |
| 297 |
disabled |
| 298 |
oneshot |
| 299 |
|
| 300 |
service mtpd /system/bin/mtpd |
| 301 |
socket mtpd stream 600 system system |
| 302 |
user vpn |
| 303 |
group vpn net_admin net_raw |
| 304 |
disabled |
| 305 |
oneshot |
| 306 |
|
| 307 |
service keystore /system/bin/keystore |
| 308 |
user keystore |
| 309 |
group keystore |
| 310 |
socket keystore stream 666 |