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