summaryrefstree
path: root/system/init.miui.rc
blob: 85eebeb2644c789bb803d6892879f376eb4dad83 (plain)
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
# miui init rc
import /init.miui8.rc
import /init.miui.google_revenue_share.rc
import /init.miui.google_revenue_share_v2.rc
import /init.miui.google_revenue_share_vdf.rc
import /init.miui.google_revenue_share_jp_sb.rc
import /init.miui.google_revenue_share_amx.rc
import /init.miui.google_revenue_share_lm_cr.rc
import /init.miui.google_revenue_share_orange.rc
import /init.miui.google_revenue_share_hk_h3g.rc
import /init.miui.google_revenue_share_tim.rc
import /init.miui.google_revenue_share_tf.rc
import /init.miui.google_revenue_share_mx_at.rc
import /init.miui.google_revenue_share_jp_kd.rc
import /init.miui.google_revenue_share_fr_sfr.rc
import /init.miui.google_revenue_share_za_mt.rc
import /init.miui.cust.rc
import /init.miui.nativedebug.rc
import /init.miui.qadaemon.rc
import /init.miui.perf_init.rc

on init
    # Create cgroup mount point for memory and freezer
    mount tmpfs none /sys/fs/cgroup mode=0750,uid=0,gid=1000
    mkdir /sys/fs/cgroup/memory 0750 root system
    mount cgroup none /sys/fs/cgroup/memory memory
    mkdir /sys/fs/cgroup/freezer 0750 root system
    mount cgroup none /sys/fs/cgroup/freezer freezer
    # set log buffersize
    setprop persist.logd.size.radio "4M"
    setprop persist.logd.size.system "4M"
    setprop persist.logd.size.crash "1M"

    # Xiaomi: Create cgroup in freezer
    mkdir /sys/fs/cgroup/freezer/perf 0750 root system
    mkdir /sys/fs/cgroup/freezer/perf/frozen 0750 root system
    write /sys/fs/cgroup/freezer/perf/frozen/freezer.state FROZEN
    chown root system /sys/fs/cgroup/freezer/perf/frozen/cgroup.procs
    chmod 0660 /sys/fs/cgroup/freezer/perf/frozen/cgroup.procs
    chown root system /sys/fs/cgroup/freezer/perf/frozen/tasks
    chmod 0660 /sys/fs/cgroup/freezer/perf/frozen/tasks
    mkdir /sys/fs/cgroup/freezer/perf/thawed 0750 root system
    chown root system /sys/fs/cgroup/freezer/perf/thawed/cgroup.procs
    chmod 0660 /sys/fs/cgroup/freezer/perf/thawed/cgroup.procs
    chown root system /sys/fs/cgroup/freezer/perf/thawed/tasks
    chmod 0660 /sys/fs/cgroup/freezer/perf/thawed/tasks

on late-init
    # set vr related cpuset
    mkdir /dev/cpuset/vr
    write /dev/cpuset/vr/mems 0

    # change permissions for vr cpusets as we'll touch at runtime
    chown root system /dev/cpuset/foreground/boost/cpus
    chown root system /dev/cpuset/foreground/cpus
    chmod 0664 /dev/cpuset/foreground/cpus
    chmod 0664 /dev/cpuset/foreground/boost/cpus
    chown system system /dev/cpuset/vr
    chown system system /dev/cpuset/vr/cpu_exclusive
    chown system system /dev/cpuset/vr/cpus
    chown system system /dev/cpuset/vr/tasks
    chmod 0664 /dev/cpuset/top-app/cpus
    chown root system /dev/cpuset/top-app/cpus
    chown system system /dev/cpuset/top-app/boost
    chown system system /dev/cpuset/top-app/boost/tasks
    chown system system /dev/cpuset/top-app/boost/cpus
    chmod 0664 /dev/cpuset/vr/cpu_exclusive
    chmod 0664 /dev/cpuset/vr/cpus
    chmod 0664 /dev/cpuset/vr/tasks
    chmod 0664 /dev/cpuset/top-app/boost/tasks

on late-init
    # put some heavy-load thread into this cpuset for performance
    mkdir /dev/cpuset/game
    write /dev/cpuset/game/mems 0
    chown system system /dev/cpuset/game
    chown system system /dev/cpuset/game/tasks
    chown system system /dev/cpuset/game/cgroup.procs
    chmod 0660 /dev/cpuset/game/tasks
    chmod 0660 /dev/cpuset/game/cgroup.procs
    # put some light-load thread into this cpuset for battery life
    mkdir /dev/cpuset/gamelite
    write /dev/cpuset/gamelite/mems 0
    chown system system /dev/cpuset/gamelite
    chown system system /dev/cpuset/gamelite/tasks
    chown system system /dev/cpuset/gamelite/cgroup.procs
    chmod 0660 /dev/cpuset/gamelite/tasks
    chmod 0660 /dev/cpuset/gamelite/cgroup.procs

on fs
   start  mqsasd

on post-fs-data
    mkdir /data/system 0775 system system
    mkdir /data/system/mcd 0755 system system
    mkdir /data/system/whetstone 0770 system system
    mkdir /data/system/migt 0777 system system
    restorecon_recursive /data/system/mcd
    restorecon_recursive /data/system/whetstone
    restorecon_recursive /data/system/migt
    restorecon /sys/kernel/debug/system_stats
    restorecon /sys/kernel/debug/msm_subsys/modem
    chmod 0777 /data/system/migt
    chmod 0777 /data/system/migt/migt

on post-fs-data
    chown system system /sys/hwconf
    chown system system /sys/hwconf/hw_info
    chown system system /sys/hwconf/hw_mon
    restorecon_recursive /sys/hwconf

# cpu trace
on post-fs-data
    chown root system /sys/kernel/ktrace/sched/pids
    chown system system /sys/kernel/ktrace/sched/zygote_pid
    chown system system /sys/kernel/ktrace/sched/zygote64_pid
    chown system system /sys/kernel/ktrace/events/mm/slowpath/reset
    restorecon_recursive /sys/kernel/ktrace

# rtmm
on post-fs-data
    chown system system /sys/kernel/mm/rtmm/reclaim/auto_reclaim
    chown system system /sys/kernel/mm/rtmm/reclaim/global_reclaim
    chown system system /sys/kernel/mm/rtmm/reclaim/proc_reclaim
    chown system system /sys/kernel/mm/rtmm/reclaim/kill
    chown system system /sys/kernel/mm/rtmm/compact/compact_memory
    restorecon_recursive /sys/kernel/mm/rtmm

on post-fs-data
    restorecon_recursive /sys/kernel/debug/kperfevents
    restorecon /sys/kernel/debug/extfrag/extfrag_index

# secureboot
service setlockstate /sbin/setlockstate
    class core
    oneshot
    seclabel u:r:vold:s0

#mdbd
service mdbd /sbin/mdbd
    class core
    socket mdbd stream 660 system system
    disabled
    seclabel u:r:mdbd:s0

service shelld /system/xbin/shelld
    class main

#service for su
service su_daemon /system/xbin/su --daemon
    class main

# service for mcd init
service mcd_init /system/bin/mcd init
    user root
    group system
    class main
    disabled
    oneshot

on property:init.svc.zygote=running
    setprop mcd.extra.params "4"
    start mcd_init

#service for mcd main service
service mcd_service /system/bin/mcd
    class main
    disabled

on property:sys.boot_completed=1
    start mcd_service
    start miui-post-boot

service mdb_svc  /system/xbin/mdb_svc
    class late_start
    disabled

service otad /bin/otad
    class main
    socket otad stream 0660 updater updater
    seclabel u:r:otad:s0

# will delete this service, /system may be invalidate yet when post-fs-data triggered
service checkpath /system/xbin/miuioneshots check-sdk-path
    class main
    user root
    group system
    disabled
    oneshot

on post-fs-data
    start checkpath

service checksdkpath /system/xbin/miuioneshots check-sdk-path
    class main
    user root
    group system
    disabled
    oneshot

on property:init.svc.zygote=running
    start checksdkpath

# for NativeDebug
on post-fs-data
    mkdir /data/system/nativedebug 0771 system system
    chown system system /data/system/nativedebug
    chmod 0771 /data/system/nativedebug
    restorecon /data/system/nativedebug

# for theme
on post-fs-data
    mkdir /data/system/theme 0775 theme theme
    chown theme theme /data/system/theme
    chmod 0775 /data/system/theme
    restorecon /data/system/theme
    chown theme theme /data/system/theme/lock_wallpaper
    chmod 0775 /data/system/theme/lock_wallpaper
    restorecon /data/system/theme/lock_wallpaper
    mkdir /data/system/theme_magic 0775 theme theme
    chown theme theme /data/system/theme_magic
    chmod 0775 /data/system/theme_magic
    restorecon /data/system/theme_magic
    mkdir /data/system/theme_magic/customized_icons 0775 theme theme
    chown theme theme /data/system/theme_magic/customized_icons
    chmod 0775 /data/system/theme_magic/customized_icons
    restorecon /data/system/theme_magic/customized_icons

service fdpp /system/bin/fdpp daemon
    class main
    user root
    group system

# mqsasd
service mqsasd /system/xbin/mqsasd daemon
    user root
    group system cache log everybody
    socket mqsasd stream 0660 system system

on post-fs-data
    mkdir /data/mqsas 0775 system system
    mkdir /data/system/miuilog 0775 system system

#adb input
on property:persist.security.adbinput=*
    restart adbd

service miui-early-boot /system/bin/sh /init.miui.early_boot.sh
    class main
    user root
    oneshot
    seclabel u:r:miui_init_shell:s0


service system_perf_init /system/xbin/system_perf_init
    class main
    user root
    disabled
    oneshot

service miui-post-boot /system/bin/sh /init.miui.post_boot.sh
    class late_start
    user root
    disabled
    oneshot

on boot
    # kperfevents
    chown system system /d/kperfevents/supervision_level
    chmod 0660 /d/kperfevents/supervision_level
    chown system system /d/kperfevents/lower_threshold_millis
    chmod 0660 /d/kperfevents/lower_threshold_millis
    chown system system /d/kperfevents/upper_threshold_millis
    chmod 0660 /d/kperfevents/upper_threshold_millis
    chown system system /d/kperfevents/min_overlap_millis
    chmod 0660 /d/kperfevents/min_overlap_millis
    chown system system /d/kperfevents/translating_kernel_address_args
    chmod 0220 /d/kperfevents/translating_kernel_address_args
    chown system system /d/kperfevents/translating_kernel_address_result
    chmod 0440 /d/kperfevents/translating_kernel_address_result
    chown system system /dev/proc_kperfevents
    chmod 0444 /dev/proc_kperfevents
    chown system system /dev/device_kperfevents
    chmod 0440 /dev/device_kperfevents

    # psi
    chmod 0660 /proc/pressure/io
    chmod 0660 /proc/pressure/memory
    chmod 0660 /proc/pressure/cpu

    # reclaim
    chown system system /sys/kernel/mi_reclaim/event

    # cpu bandwidth
    mkdir /dev/cpuctl/background
    chown system system /dev/cpuctl/background/tasks
    chmod 0666 /dev/cpuctl/background/tasks
    write /dev/cpuctl/background/cpu.shares 384
    write /dev/cpuctl/background/cpu.rt_period_us 1000000
    write /dev/cpuctl/background/cpu.rt_runtime_us 400000

    chown root system /sys/module/millet_core/parameters/millet_freeze_switch

on property:persist.sys.miui_bg_binder=true
    write /sys/kernel/debug/binder/bg_enable "1"

on property:persist.sys.miui_spo_test=true
    write /cache/boot_flag "disable"

on property:sys.sptm.gover=true
    write /sys/devices/system/cpu/cpufreq/policy0/scaling_governor "performance"
    write /sys/devices/system/cpu/cpufreq/policy4/scaling_governor "performance"
    write /sys/devices/system/cpu/cpufreq/policy7/scaling_governor "performance"

on property:sys.sptm.gover=false
    write /sys/devices/system/cpu/cpufreq/policy0/scaling_governor "schedutil"
    write /sys/devices/system/cpu/cpufreq/policy4/scaling_governor "schedutil"
    write /sys/devices/system/cpu/cpufreq/policy7/scaling_governor "schedutil"

on property:sys.boot_completed=1 && property:ro.debuggable=1
    # 工厂running测试需求
    # gsort路径权限打开
    chmod 0777 /dev/block/sda5
    # input_suspend节点权限打开
    chown system system sys/class/power_supply/battery/input_suspend
    chmod 0777 sys/class/power_supply/battery/input_suspend
    # /data/local/tmp路径权限打开
    mkdir /data/local/tmp
    chown system system /data/local/tmp
    chmod 0777 /data/local/tmp

# MI ADD
# miui bugreport need to get bugreport

# on property:sys.miui.bugreport_file=*
# on property:sys.miui.dest_path=*
# start copy_bugreport_file

service copy_bugreport_file /system/bin/sh /system/bin/copy_bugreport_file.sh ${sys.miui.bugreport_file} ${sys.miui.dest_path}
    user shell
    group shell sdcard_rw system net_raw
    oneshot
    disabled
    seclabel u:r:shell:s0
#-MI ADD