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