Chinaunix首页 | 论坛 | 博客
  • 博客访问: 540938
  • 博文数量: 75
  • 博客积分: 2374
  • 博客等级: 大尉
  • 技术积分: 933
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-18 14:27
文章分类

全部博文(75)

文章存档

2014年(1)

2013年(17)

2012年(10)

2011年(15)

2010年(23)

2009年(9)

我的朋友

分类: 嵌入式

2012-05-24 20:27:41

init.rc相当于是init程序的配置文件。如何看懂它对于了解Android挺有帮助的。
文章的末尾是摘自init的readme原文
不翻译了,英语太蹩脚,翻了估计更看不懂。
以下是自己总结的几个,方便查看而已。

Actions由一系列commands组成,不过有一定的trigger条件,只要条件满足,将执行Actions下面的所有commands。它的形式是:


  1. on
  2.  
  3.  
  4.  
Services由Init程序启动。它后面一般都跟着好多options。它的形式是:

  1. service [ ]*
  2.    
  3.    
  4.     ...
而option又有以下几种:
critical:有该option的service,表示当service挂掉的时候,在一定时间内还没发重启,那么设备将进入recovery模式。个人体验就是机子死机了,过会儿自个重启,但是在手机状态中查看开机时间时又不是从零开始的。
disabled:service不会随着它所在的class自动重启
oneshot:仅运行一次,不会有重启service的可能。
onrestart:service重启后,运行后面的command
其他等等

至于command参见下面的英语原文。
-----------------------


Android Init Language
---------------------

The Android Init Language consists of four broad classes of statements,
which are Actions, Commands, Services, and Options.

All of these are line-oriented, consisting of tokens separated by
whitespace.  The c-style backslash escapes may be used to insert
whitespace into a token.  Double quotes may also be used to prevent
whitespace from breaking text into multiple tokens.  The backslash,
when it is the last character on a line, may be used for line-folding.

Lines which start with a # (leading whitespace allowed) are comments.

Actions and Services implicitly declare a new section.  All commands
or options belong to the section most recently declared.  Commands
or options before the first section are ignored.

Actions and Services have unique names.  If a second Action or Service
is declared with the same name as an existing one, it is ignored as
an error.  (??? should we override instead)


Actions
-------
Actions are named sequences of commands.  Actions have a trigger which
is used to determine when the action should occur.  When an event
occurs which matches an action's trigger, that action is added to
the tail of a to-be-executed queue (unless it is already on the
queue).

Each action in the queue is dequeued in sequence and each command in
that action is executed in sequence.  Init handles other activities
(device creation/destruction, property setting, process restarting)
"between" the execution of the commands in activities.

Actions take the form of:

on
  
  
  


Services
--------
Services are programs which init launches and (optionally) restarts
when they exit.  Services take the form of:

service [ ]*
  
阅读(5426) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~