Repository navigation
Expand file tree
/
Copy pathfactory_init.rc
More file actions
540 lines (425 loc) · 14.9 KB
/
Copy pathfactory_init.rc
File metadata and controls
540 lines (425 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
import /init.environ.rc
on early-init
# Set init and its forked children's oom_adj.
write /proc/1/oom_score_adj -1000
# Set the security context of /adb_keys if present.
restorecon /adb_keys
start ueventd
write /proc/bootprof "INIT: usr/eng build setting"
# create mountpoints
mkdir /mnt 0775 root system
mount debugfs /sys/kernel/debug /sys/kernel/debug
setprop ro.mtk.hardware mt6582
mkdir /storage 0055 system sdcard_r
mkdir /storage/sdcard0 0000 system system
# for backwards compatibility
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
on init
sysclktz 0
loglevel 5
# Backward compatibility
symlink /system/etc /etc
symlink /sys/kernel/debug /d
# Right now vendor lives on the same filesystem as system,
# but someday that may change.
symlink /system/vendor /vendor
# Create cgroup mount point for cpu accounting
mkdir /acct
mount cgroup none /acct cpuacct
mkdir /acct/uid
mkdir /system
mkdir /data 0771 system system
mkdir /cache 0770 system cache
mkdir /config 0500 root root
mkdir /protect_f 0771 system system
mkdir /protect_s 0771 system system
# Filesystem image public mount points.
mkdir /mnt/obb 0700 root system
mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
write /proc/sys/kernel/sched_compat_yield 1
write /proc/sys/kernel/sched_child_runs_first 0
# Healthd can trigger a full boot from charger mode by signaling this
# property when the power button is held.
on property:sys.boot_from_charger_mode=1
class_stop charger
trigger late-init
# Load properties from /system/ + /factory after fs mount.
on load_all_props_action
load_all_props
start logd
start logd-reinit
# Indicate to fw loaders that the relevant mounts are up.
on firmware_mounts_complete
rm /dev/.booting
# Mount filesystems and start core system services.
on late-init
trigger early-fs
trigger fs
trigger post-fs
trigger post-fs-data
# Load properties from /system/ + /factory after fs mount. Place
# this in another action so that the load will be scheduled after the prior
# issued fs triggers have completed.
trigger load_all_props_action
# Remove a file to wake up anything waiting for firmware.
trigger firmware_mounts_complete
trigger early-boot
trigger boot
# mount different fs start
on fs
write /proc/bootprof "INIT:eMMC:Mount_All_START"
mount_all /fstab.sprout
write /proc/bootprof "INIT:eMMC:Mount_All_END"
#for SD card with partition(s), always mount the 1st
mount vfat /dev/block/mmcblk1p1 /storage/sdcard0
#for SD card without any partition.
mount vfat /dev/block/mmcblk1 /storage/sdcard0
# mount different fs end
on post-fs
# once everything is setup, no need to modify /
mount rootfs rootfs / ro remount
mkdir /system/cache 0770 system cache
# We chown/chmod /cache again so because mount is run as root + defaults
chown system cache /cache
chmod 0770 /cache
# We restorecon /cache in case the cache partition has been reset.
restorecon_recursive /cache
mkdir /cache/recovery 0770 system system
chown system system /protect_f
chmod 0771 /protect_f
chown system system /protect_s
chmod 0771 /protect_s
# This may have been created by the recovery system with odd permissions
chown system cache /cache/recovery
chmod 0770 /cache/recovery
#change permissions on vmallocinfo so we can grab it from bugreports
chown root log /proc/vmallocinfo
chmod 0440 /proc/vmallocinfo
#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
chown root system /proc/kmsg
chmod 0440 /proc/kmsg
chown root system /proc/sysrq-trigger
chmod 0220 /proc/sysrq-trigger
# make the selinux kernel policy world-readable
chmod 0444 /sys/fs/selinux/policy
on post-fs-data
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
# We restorecon /data in case the userdata partition has been reset.
restorecon /data
# Emulated internal storage area
mkdir /data/media 0770 media_rw media_rw
# Make sure we have the device encryption key
start logd
start vold
installkey /data
# create basic filesystem structure
mkdir /data/nvram 0771 root system
mkdir /data/nvram/bt 2771 bluetooth bluetooth
mkdir /data/nvram/media 0771 media audio
mkdir /data/misc 01771 system misc
mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/keychain 0771 system system
mkdir /data/misc/vpn 0770 system vpn
mkdir /data/misc/systemkeys 0700 system system
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
mkdir /data/local 0771 shell shell
mkdir /data/local/tmp 0771 shell shell
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root
mkdir /data/misc/media 0700 media media
mkdir /data/misc/vold 0700 root root
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770
mkdir /cache/lost+found 0770
# double check the perms, in case lost+found already exists, and set owner
chown root root /data/lost+found
chmod 0770 /data/lost+found
chown root root /cache/lost+found
chmod 0770 /cache/lost+found
mkdir /data/adb 0700 root root
# dhcp server
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
# device info interface
chmod 0444 /dev/devmap
chown root system /dev/devmap
#change partition permission
exec /system/etc/partition_permission.sh
## Custom pos-fs area (START)
# Please add custom fs operation below
#
# Connectivity related modules and character device nodes (Begin)
#
#/dev/ttyMT2 for 662x_launcher
chmod 0660 /dev/ttyMT2
chown system system /dev/ttyMT2
chmod 0660 /dev/ttyMT1
chown system system /dev/ttyMT1
# WiFi
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
mkdir /data/misc/wpa_supplicant 0770 wifi wifi
#
# Connectivity related modules and character device nodes (End)
#
# Touch Panel
chown root diag /sys/module/tpd_setting/parameters/tpd_calmat
chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time
chown root diag /sys/module/tpd_debug/parameters/tpd_em_log
chown root diag /sys/module/tpd_debug/parameters/tpd_em_log_to_fs
chmod 0770 /dev/pmem_multimedia
# RTC
mkdir /data/misc/rtc 0770 system system
# Modem related device nodes
mkdir /data/nvram/md 0770 root system
# CCCI
chown radio radio /sys/kernel/ccci/boot
# M4U
#insmod /system/lib/modules/m4u.ko
#mknod /dev/M4U_device c 188 0
chmod 0444 /dev/M4U_device
# Sensor
chmod 0660 /dev/hwmsensor
chmod 0660 /dev/gyroscope
chmod 0660 /dev/msensor
chmod 0660 /dev/gsensor
chmod 0660 /dev/alsps
#VideoCodec
chmod 0660 /dev/Vcodec
chown system media /dev/Vcodec
mkdir /data/amit/
# GPIO
chmod 0660 /dev/mtgpio
# Android SEC related device nodes
chmod 0660 /dev/sec
chown root system /dev/sec
# device info interface
chmod 0440 /dev/devmap
chown root system /dev/devmap
#change partition permission
exec /system/etc/partition_permission.sh
chmod 0660 /dev/exm0
# Separate location for storing security policy files on data
mkdir /data/security 0711 system system
# Create all remaining /data root dirs so that they are made through init
# and get proper encryption policy installed
mkdir /data/backup 0700 system system
mkdir /data/media 0770 media_rw media_rw
mkdir /data/ss 0700 system system
mkdir /data/system 0775 system system
mkdir /data/system/heapdump 0700 system system
mkdir /data/user 0711 system system
# Reload policy from /data/security if present.
setprop selinux.reload_policy 1
# Set SELinux security contexts on upgrade or policy update.
restorecon_recursive /data
# Check any timezone data in /data is newer than the copy in /system, delete if not.
exec - system system -- /system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo
## Custom pos_fs area (END)
# If there is no fs-post-data action in the init.<device>.rc file, you
# must uncomment this line, otherwise encrypted filesystems
# won't work.
# Set indication (checked by vold) that we have finished this action
setprop vold.post_fs_data_done 1
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
mount vfat /dev/block/mmcblk1p1 /storage/sdcard0
mount vfat /dev/block/mmcblk1 /storage/sdcard
# Start default class, this line is very important!!
class_start default
class_start core
on nonencrypted
class_start main
class_start late_start
on property:vold.decrypt=trigger_default_encryption
start defaultcrypto
on property:vold.decrypt=trigger_encryption
start surfaceflinger
start encrypt
on property:sys.init_log_level=*
loglevel ${sys.init_log_level}
on property:vold.decrypt=trigger_reset_main
class_reset main
start stop_modem
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
start logd
start logd-reinit
on property:vold.decrypt=trigger_post_fs_data
trigger post-fs-data
on property:vold.decrypt=trigger_restart_min_framework
class_start main
start start_modem
on property:vold.decrypt=trigger_restart_framework
class_start main
class_start late_start
start nvram_daemon
start start_modem
on property:vold.decrypt=trigger_shutdown_framework
class_reset late_start
class_reset main
start stop_modem
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service stop_modem /system/bin/md_ctrl 0
class main
disabled
oneshot
service start_modem /system/bin/md_ctrl 1
class main
disabled
oneshot
## Daemon processes to be run by init.
##
service ueventd /sbin/ueventd
class core
critical
seclabel u:r:ueventd:s0
service logd /system/bin/logd
class core
socket logd stream 0666 logd logd
socket logdr seqpacket 0666 logd logd
socket logdw dgram 0222 logd logd
seclabel u:r:logd:s0
service logd-reinit /system/bin/logd --reinit
oneshot
disabled
service console /system/bin/sh
class core
console
disabled
user shell
group shell log
seclabel u:r:shell:s0
on property:ro.debuggable=1
start console
# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
class core
socket adbd stream 660 system system
disabled
seclabel u:r:adbd:s0
service vold /system/bin/vold \
--blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 \
--fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0
class core
socket vold stream 0660 root mount
socket cryptd stream 0660 root mount
ioprio be 2
# One shot invocation to deal with encrypted volume.
service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
disabled
oneshot
# vold will set vold.decrypt to trigger_restart_framework (default
# encryption) or trigger_restart_min_framework (other encryption)
# One shot invocation to encrypt unencrypted volumes
service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
disabled
oneshot
# vold will set vold.decrypt to trigger_restart_framework (default
# encryption)
## Custom service area (START)
# Please add custom service below
service ccci_fsd /system/bin/ccci_fsd 0
user radio
group radio system
oneshot
service ccci_mdinit /system/bin/ccci_mdinit 0
user system
group radio system
oneshot
service nvram_daemon /system/bin/nvram_daemon
class main
user root
group system bluetooth
oneshot
service dualmdlogger /system/bin/dualmdlogger
class main
user shell
group shell system radio sdcard_rw inet
disabled
oneshot
service installd /system/bin/installd
class main
socket installd stream 600 system system
service factory_no_image /storage/sdcard0/factory/bin/factory
disable
oneshot
#
# Connectivity related services (Begin)
#
service wmtLoader /system/bin/wmt_loader
user root
group root
oneshot
service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/
user system
group system
oneshot
service wlanLoader /system/bin/wlan_loader
user root
group root
oneshot
#service hald /system/bin/hald
# class main
# socket hald stream 0660 root system
#service wpa_supplicant /system/bin/wpa_supplicant
# group wifi
# disabled
# oneshot
#
# Connectivity related services (End)
#
#
## Custom service area (END)
on property:sys.mtk.no.factoryimage=1
start factory_no_image
on property:persist.logd.logpersistd=logcatd
# all exec/services are called with umask(077), so no gain beyond 0700
mkdir /data/misc/logd 0700 logd log
# logd for write to /data/misc/logd, log group for read from pstore (-L)
exec - logd log -- /system/bin/logcat -L -b all -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 64 -n 256
start logcatd
service logcatd /system/bin/logcat -b all -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 64 -n 256
class late_start
disabled
# logd for write to /data/misc/logd, log group for read from log daemon
user logd
group log
#mass_storage,adb,acm
on property:sys.usb.com_config=0
write /sys/class/android_usb/android0/iSerial $ro.serialno
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 0bb4
write /sys/class/android_usb/android0/idProduct 0005
write /sys/class/android_usb/android0/f_acm/instances 1
write /sys/class/android_usb/android0/functions mass_storage,adb,acm
write /sys/class/android_usb/android0/enable 1
start adbd
#acm
on property:sys.usb.com_config=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/iSerial " "
write /sys/class/android_usb/android0/idVendor 0e8d
write /sys/class/android_usb/android0/idProduct 2007
write /sys/class/android_usb/android0/f_acm/instances 1
write /sys/class/android_usb/android0/functions acm
write /sys/class/android_usb/android0/bDeviceClass 02
write /sys/class/android_usb/android0/enable 1