Android Init语言
Android Init语言是一种特别简单的语言,专门用来写Android的Init进程使用的配置文件的。
相当于Linux系统中的rc文件(这句话对于Linux者多半是句废话)。
Android Init语言主要有四部分组成,分别是Actions, Commands, Services和Options。
语法的四个组成部分,都是面向行的,每行都对应一个操作,在行里的用空格(注:空格,\t, \r)
来区分不同的token。如果想要在token中插入一个空格,需要使用反斜线+空格的方式。另外双引号
也可以让一个token中出现的空格部位一般意义的空格,而不是一个分割符。 如果某一行过长的话,
可以在行尾使用 反斜线连接同一行的内容
用#可以注释掉一行。Action和Service都是块(SECTION), 所有的Command或者Option属于离它
最近的那个块。出现在第一个块之外的Command和Option都是无效的。注意下,Command组成了Action,
而Service的属性都是Option
Action和Service都有一个唯一的名字。如果出现第二个同名的Action或者Service,那么第二个
Action或者Service会被认为是一个错误
Action实际上就是一组命令的名字而已。Action的名字之后跟着一个触发器。这个触发器才是决定
这一组命令在何时开始执行。假如系统中发生的事件,和当前Action的触发器相匹配的话,那么这个
Action中这组命令就会被添加到一个等到执行的列表的末尾。
每一个Action都是在执行队列中顺序执行的。Init进程在执行这个队列的之余还会处理一些其他事情,
比如设备的插入或者拔出,属性的设定或者某些进程的重启等。
on <trigger>
<command>
<command>
<command>
Service是一个可执行程序,这个可执行程序由init进程启动。当Service在退出时
根据选择可以重启这个Service
service <name> <pathname> [ <argument> ]*
<option>
<option>
...
Option定义了Service在启动或者退出时一些属性或者操作. Option会影响Service在何时
,如何启动和运行一个Service
critical
如果一个critical Service在4分钟内退出了4次,那么设备就要重启进入Recovery模式
disabled
表示这个Service不会在同一类别service启动时自动启动。这样的service必须使用名字启动
setenv <name> <value>
设定这个service启动所在进程的环境变量
下面这几个属性,和selinux相关的规则设置。
socket <name> <type> <perm> [ <user> [ <group> ] ]
Create a unix domain socket named /dev/socket/<name> and pass
its fd to the launched process. <type> must be "dgram", "stream" or "seqpacket".
User and group default to 0.
user <username>
Change to username before exec'ing this service.
Currently defaults to root. (??? probably should default to nobody)
Currently, if your process requires linux capabilities then you cannot use
this command. You must instead request the capabilities in-process while
still root, and then drop to your desired uid.
group <groupname> [ <groupname> ]*
Change to groupname before exec'ing this service. Additional
groupnames beyond the (required) first one are used to set the
supplemental groups of the process (via setgroups()).
Currently defaults to root. (??? probably should default to nobody)
seclabel <securitycontext>
这个是和selinux的管理策略有关的。这个东西要细细地研究啊
oneshot
当service退出时,不会重新启动这个service
class <name>
为Service分类使用的,每个Service都属于某个类,init进程
可以一次启动和停止一个类别中的所有service。 如果Service中
没有这个class的话,默认的是“default”类
onrestart
当Service重启时会重启一些启动的依赖的Service
触发器就是一个字符串,当某个字符串和触发器匹配成功时,那么这个
action下面的一系列命令就开始执行了。
boot
This is the first trigger that will occur when init starts
(after /init.conf is loaded)
<name>=<value>
Triggers of this form occur when the property <name> is set
to the specific value <value>.
device-added-<path>
device-removed-<path>
Triggers of these forms occur when a device node is added
or removed.
service-exited-<name>
Triggers of this form occur when the specified service exits.
这里面的命令大部分和Linux相同,比如copy,read, write, chdir等函数,
不过下面这些是Android特有的,在Linux基础上补充进去的
class_start <serviceclass>
如果某一类的服务还没有启动的话,启动serviceclass这一类别种所有的service。
class_stop <serviceclass>
如果某一类服务正在运行,那么停止serviceclass这一类别种所有的service。
setprop <name> <value>
设置系统属性的命令,属性就是一个键值对
setrlimit <resource> <cur> <max>
start <service>
如果某个服务还没有启动的话,那么就启动这个服务
stop <service>
如果某个服务正在运行的话,那么久停止这个服务的运行
trigger <event>
从一个Action中触发另外一个Action
Properties
Init updates some system properties to provide some insight into
what it's doing:
init.action
Equal to the name of the action currently being executed or "" if none
init.command
Equal to the command being executed or "" if none.
init.svc.<name>
State of a named service ("stopped", "running", "restarting")
Android Init语言的更多相关文章
- Android C语言_init函数和constructor属性及.init/.init_array节探索
本篇文章主要介绍了"Android C语言_init函数和constructor属性及.init/.init_array节探索",主要涉及到Android C语言_init函数和c ...
- Android init.rc解析【转】
转自:http://www.linuxidc.com/Linux/2014-10/108438.htm 本文主要来自$Android_SOURCE/system/init/readme.txt的翻译. ...
- Android init.rc文件浅析
Android init.rc文件浅析 分类: Android2012-04-13 18:00 13149人阅读 评论(2) 收藏 举报 androidservicepathactionsocketc ...
- 【Android 多语言切换简单实例分享】
一.Android多语言切换 Android应用的开发不可能仅仅针对某一个国家或者区域使用,各国间语言文化各不同样,因此一个优秀的APP必须支持多种语言,为了实现这个特性,Android给出了一个解决 ...
- android init进程分析 init脚本解析和处理
(懒人近期想起我还有csdn好久没打理了.这个android init躺在我的草稿箱中快5年了.略微改改发出来吧) RC文件格式 rc文件是linux中常见的启动载入阶段运行的文件.rc是run co ...
- Android init介绍(下)
上一篇请参考<Android init介绍(上)> 5. AIL 在init启动过程中,系统服务等均是通过解析rc文件来启动,而rc文件则是由Android初始化语言(Android In ...
- android init进程分析 ueventd
转自:http://blog.csdn.net/freshui/article/details/2132299 (懒人最近想起我还有csdn好久没打理了,这个Android init躺在我的草稿箱中快 ...
- Android 多语言
Android 多语言 在res文件上右击创建新的values文件 在strings文件中设置多语言 3.在layout文件中使用 @strings/key 引用相应资源
- Android init.rc文件格式解析
/***************************************************************************** * Android init.rc文件格式 ...
随机推荐
- 扯谈spring mvc之WebApplicationContext的继承关系
spring mvc里的root/child WebApplicationContext的继承关系 在传统的spring mvc程序里会有两个WebApplicationContext,一个是pare ...
- -_-#【userAgent】极速模式与非极速模式存在差异
UC浏览器 Android 极速模式 UC浏览器 Android 非极速模式
- SET NOCOUNT (Transact-SQL)
阻止在结果集中返回显示受 Transact-SQL 语句或存储过程影响的行计数的消息. 语法 SET NOCOUNT { ON | OFF } 注释 当 SET NOCOUNT 为 ON 时,不返回 ...
- SQL SELECT INTO 语句
SQL SELECT INTO 语句可用于创建表的备份复件. SELECT INTO 语句 SELECT INTO 语句从一个表中选取数据,然后把数据插入另一个表中. SELECT INTO 语句常用 ...
- Tuna项目总结
从8.19—9.13日一共四周的时间,我在Tuna项目组进行的我的第一次正式工作,以及学习.在此,我对这个阶段的工作及学习进行一个总结,主要分为对流程的理解和对自动化测试的应用两个方面. 在总结着两点 ...
- 设计模式学习--复合模式(Compound Pattern)
设计模式学习--复合模式(Compound Pattern) 概述 ——————————————————————————————————————————————————— 2013年8月4日<H ...
- Python之路【第一篇】:Python前世今生
Python简介 Python前世今生 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解 ...
- python_Opencv_使用Matplotlib模块
使用Matplotlib模块 Matplotib 是python 的一个绘图库,里头有各种各样的绘图方法. 之后会陆续了解.先学习怎样用Matplotib 显示图像. 可以放大图像,保存图像. 安装M ...
- ListView的优化
1. ListView须要设置adapter,它的item是通过adapter的方法getView(int position, View convertView, ViewGroup parent)获 ...
- linux boost 安装
sudo apt-get install libboost-dev 但是,我这样安装以后,编译程序时出现了很多错误,而且都是系统文件的错误.我开始以为是我的boost库版本不对,后来换了好几个版本,都 ...