- 3.4.2 init.rc的内容
- 关键字on声明一个Action, early-init是该Action的触发器,也是Action的名字
- Set init and its forked children's oom_adj.
- create mountpoints
- 关键字on声明另外一个Action, property:ro.debuggable=1是该Action的触发器
- 这个触发器由property关键字指定,即在ro.debuggable属性的值被设为1的时候触发start命令
- 关键字service声明了一个Service,该Service的名字为servicemanager
- Service对应的命令的路径是/system/bin/servicemanager,没有参数可传入
- critical关键字声明的Option,该Service 4分钟内重启4次
- 将导致系统重启进入recovery模式
- onrestart关键字声明的Option,指定该Service重启后要执行的Command
- restart zygote是一个Command, restart对应的处理函数是do_restart
- 声明一个名为zygote的Service,命令路径是/system/bin/app_process
- 传入参数是-Xzygote/system/bin—zygote—start-system-server
3.4.2 init.rc的内容
熟悉了Android初始化语言,再来阅读init.rc文件就容易多了。以下是init.rc的内容:
关键字on声明一个Action, early-init是该Action的触发器,也是Action的名字
on early-init
Set init and its forked children's oom_adj.
write/proc/1/oom_adj-16#这里是一个write关键字指定的Command
start ueventd#这里是一个start关键字指定的Command
create mountpoints
mkdir/mnt 0775 root system#这里是一个mkdir关键字指定的Command
……//省略部分内容
关键字on声明另外一个Action, property:ro.debuggable=1是该Action的触发器
这个触发器由property关键字指定,即在ro.debuggable属性的值被设为1的时候触发start命令
on property:ro.debuggable=1
start console
关键字service声明了一个Service,该Service的名字为servicemanager
Service对应的命令的路径是/system/bin/servicemanager,没有参数可传入
service servicemanager/system/bin/servicemanager
class core#class关键字声明的Option,该Service属于core类别
user system#user关键字声明的Option,该Service属于system用户
group system
critical关键字声明的Option,该Service 4分钟内重启4次
将导致系统重启进入recovery模式
critical
onrestart关键字声明的Option,指定该Service重启后要执行的Command
restart zygote是一个Command, restart对应的处理函数是do_restart
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm
……//省略部分内容
声明一个名为zygote的Service,命令路径是/system/bin/app_process
传入参数是-Xzygote/system/bin—zygote—start-system-server
service zygote/system/bin/app_process
-Xzygote/system/bin—zygote—start-system-server
class main
socket zygote stream 660 root system
onrestart write/sys/android_power/request_state wake
onrestart write/sys/power/state on
onrestart restart media
onrestart restart netd