本文主要介绍rc 语法,参考官方文档
init.rc 格式文档
init.rc
主要四个点:
- Action(动作)---》对应下面的on <trigger> [&& <trigger>]*
- Commands(命令)--》<command>
- Services(服务)--》service <name> <pathname> [ <argument> ]*
- Options(选项)--》<option>
on <trigger> [&& <trigger>]*
<command>
<command>
<command>
service <name> <pathname> [ <argument> ]*
<option>
<option>
...
1 先介绍action ,on与command 组合使用
在init.target.rc 中写法如下
on early-init
exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules pinctrl-wcd wcd-dsp-glink snd-soc-wcd-spi snd-soc-sdm845
write /proc/sys/kernel/sched_boost 1
mkdir /dsp 0771 media media
mkdir /firmware 0771 system system
mkdir /bt_firmware 0771 system system
symlink /data/tombstones /tombstones
other 其他举例:
on boot
setprop a 1
setprop b 2
on boot && property:true=true
setprop c 1
setprop d 2
on boot
setprop e 1
setprop f 2
trigger:

commands: 说明,更多可以参考官网

2 service 与options组合使用
在init.target.rc 中service写法如下
service thermal-engine /system/vendor/bin/thermal-engine
class main
user root
socket thermal-send-client stream 0666 system system
socket thermal-recv-client stream 0660 system system
socket thermal-recv-passive-client stream 0666 system system
socket thermal-send-rule stream 0660 system system
group root
options:

3 import
在设计中,可能使用上面的service action 就足够了,如果使用import 就参考官方README.txt
网友评论