Android Init Language
---------------------
The Android Init Language consists of five broad classes of statements:
Actions, Commands, Services, Options, and Imports.
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.
System properties can be expanded using the syntax
`${property.name}`. This also works in contexts where concatenation is
required, such as `import /init.recovery.${ro.hardware}.rc`.
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.
Services have unique names. If a second Service is defined
with the same name as an existing one, it is ignored and an error
message is logged.
Init .rc Files
--------------
The init language is used in plain text files that take the .rc file
extension. There are typically multiple of these in multiple
locations on the system, described below.
/init.rc is the primary .rc file and is loaded by the init executable
at the beginning of its execution. It is responsible for the initial
set up of the system.
Init loads all of the files contained within the
/{system,vendor,odm}/etc/init/ directories immediately after loading
the primary /init.rc. This is explained in more details in the
Imports section of this file.
Legacy devices without the first stage mount mechanism previously were
able to import init scripts during mount_all, however that is deprecated
and not allowed for devices launching after Q.
The intention of these directories is:
1. /system/etc/init/ is for core system items such as
SurfaceFlinger, MediaService, and logd.
2. /vendor/etc/init/ is for SoC vendor items such as actions or
daemons needed for core SoC functionality.
3. /odm/etc/init/ is for device manufacturer items such as
actions or daemons needed for motion sensor or other peripheral
functionality.
All services whose binaries reside on the system, vendor, or odm
partitions should have their service entries placed into a
corresponding init .rc file, located in the /etc/init/
directory of the partition where they reside. There is a build
system macro, LOCAL\_INIT\_RC, that handles this for developers. Each
init .rc file should additionally contain any actions associated with
its service.
An example is the userdebug logcatd.rc and Android.mk files located in the
system/core/logcat directory. The LOCAL\_INIT\_RC macro in the
Android.mk file places logcatd.rc in /system/etc/init/ during the
build process. Init loads logcatd.rc during the mount\_all command and
allows the service to be run and the action to be queued when
appropriate.
This break up of init .rc files according to their daemon is preferred
to the previously used monolithic init .rc files. This approach
ensures that the only service entries that init reads and the only
actions that init performs correspond to services whose binaries are in
fact present on the file system, which was not the case with the
monolithic init .rc files. This additionally will aid in merge
conflict resolution when multiple services are added to the system, as
each one will go into a separate file.
Actions
-------
Actions are named sequences of commands. Actions have a trigger which
is used to determine when the action is executed. 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 <trigger> [&& <trigger>]*
<command>
<command>
<command>
Actions are added to the queue and executed based on the order that
the file that contains them was parsed (see the Imports section), then
sequentially within an individual file.
For example if a file contains:
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
Then when the `boot` trigger occurs and assuming the property `true`
equals `true`, then the order of the commands executed will be:
setprop a 1
setprop b 2
setprop c 1
setprop d 2
setprop e 1
setprop f 2
Services
--------
Services are programs which init launches and (optionally) restarts
when they exit. Services take the form of:
service <name> <pathname> [ <argument> ]*
<option>
<option>
...
Options
-------
Options are modifiers to services. They affect how and when init
runs the service.
`capabilities [ <capability>\* ]`
> Set capabilities when exec'ing this service. 'capability' should be a Linux
capability without the "CAP\_" prefix, like "NET\_ADMIN" or "SETPCAP". See
http://man7.org/linux/man-pages/man7/capabilities.7.html for a list of Linux
capabilities.
If no capabilities are provided, then all capabilities are removed from this service, even if it
runs as root.
`class <name> [ <name>\* ]`
> Specify class names for the service. All services in a
named class may be started or stopped together. A service
is in the class "default" if one is not specified via the
class option. Additional classnames beyond the (required) first
one are used to group services.
The `animation` class should include all services necessary for both
boot animation and shutdown animation. As these services can be
launched very early during bootup and can run until the last stage
of shutdown, access to /data partition is not guaranteed. These
services can check files under /data but it should not keep files opened
and should work when /data is not available.
`console [<console>]`
> This service needs a console. The optional second parameter chooses a
specific console instead of the default. The default "/dev/console" can
be changed by setting the "androidboot.console" kernel parameter. In
all cases the leading "/dev/" should be omitted, so "/dev/tty0" would be
specified as just "console tty0".
This option connects stdin, stdout, and stderr to the console. It is mutually exclusive with the
stdio_to_kmsg option, which only connects stdout and stderr to kmsg.
`critical`
> This is a device-critical service. If it exits more than four times in
four minutes or before boot completes, the device will reboot into bootloader.
`disabled`
> This service will not automatically start with its class.
It must be explicitly started by name or by interface name.
`enter_namespace <type> <path>`
> Enters the namespace of type _type_ located at _path_. Only network namespaces are supported with
_type_ set to "net". Note that only one namespace of a given _type_ may be entered.
`file <path> <type>`
> Open a file path and pass its fd to the launched process. _type_ must be
"r", "w" or "rw". For native executables see libcutils
android\_get\_control\_file().
`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)
`interface <interface name> <instance name>`
> Associates this service with a list of the HIDL services that it provides. The interface name
must be a fully-qualified name and not a value name. For instance, this is
没有合适的资源?快使用搜索试试~ 我知道了~
Android 系统相关学习笔记.zip
共126个文件
md:43个
rsp:15个
d:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 117 浏览量
2022-12-01
11:25:54
上传
评论 1
收藏 1.48MB ZIP 举报
温馨提示
Android 系统相关学习笔记.zip
资源推荐
资源详情
资源评论
收起资源包目录
Android 系统相关学习笔记.zip (126个子文件)
vendor.unique.smartpa@1.0-adapter 57KB
Android.bp 1KB
Android.bp 297B
Android.bp 96B
vendor.unique.smartpa@1.0-adapter.config 2KB
SmartPaCallAll.cpp 18KB
SmartPaCall.vts.cpp 5KB
SmartPaCall.vts.cpp 4KB
SmartpaService.cpp 1KB
ASmartPaCall.cpp 834B
SmartPaCall.cpp 603B
main.cpp 273B
vendor.unique.smartpa@1.0-impl.so.d 742B
vendor.unique.smartpa@1.0-adapter.d 698B
vendor.unique.smartpa@1.0-impl.so.toc.d 291B
SmartPaCallAll.cpp.d 211B
srcs.srcjar.d 211B
ASmartPaCall.cpp.d 209B
SmartPaCall.vts.d 208B
ASmartPaCall.h.d 207B
ISmartPaCall.h.d 207B
main.cpp.d 175B
classes.dex 16KB
classes.dex 9KB
.gitignore 278B
BsSmartPaCall.h 15KB
ISmartPaCall.h 11KB
BpHwSmartPaCall.h 3KB
SmartPaCall.vts.h 3KB
BnHwSmartPaCall.h 2KB
SmartPaCall.vts.h 1KB
ASmartPaCall.h 976B
SmartPaCall.h 920B
IHwSmartPaCall.h 599B
ISmartPaCall.hal 216B
ISmartPaCall.java 26KB
Main.jpg 127KB
InputReader投递event.jpg 91KB
InputReader投递event.jpg 91KB
R-protolog.conf.json 83KB
Generic.kl 9KB
LICENSE 11KB
EventLogTags.logtags 56KB
init启动流程log.md 117KB
Android R startActivity 流程(二) ActivityTaskManagerService处理.md 89KB
Android 12 进程native crash流程分析.md 89KB
Android 12 Java trace 生成过程分析.md 88KB
Android R input 之 InputDispatcher 工作流程.md 86KB
Android R startActivity 流程(三) Resume Activity.md 72KB
Android R input 之 InputReader 工作流程.md 70KB
Android 12 应用Java crash流程分析.md 67KB
am命令的使用及实现流程分析.md 65KB
Android 12 关机重启流程.md 58KB
init(1) 启动流程分析.md 51KB
Android R WindowManagerService 添加window过程分析 (一) .md 51KB
InputManagerService的创建与InputChannel的注册.md 46KB
Android S input 之触摸事件派发流程.md 43KB
init(3) 属性服务.md 43KB
README.md 41KB
PostFork流程与SignalCatcher启动.md 40KB
init(2) rc脚本解析和事件执行流程.md 38KB
Android R WindowManagerService 添加window过程分析 (二) .md 36KB
Android R WindowManagerService 添加window过程分析 (三) 之InputChannel的建立.md 36KB
Watchdog(4) Trace生成过程.md 36KB
Android R InputChannel之发送事件处理反馈.md 35KB
Android R Input之ANR的产生与显示流程.md 34KB
Watchdog(5) 案例分析集.md 31KB
Android Activity之Window的创建过程.md 28KB
Android R InputManagerService 的建立.md 28KB
Android学习笔记之理解Window与WindowManager.md 27KB
Watchdog(2) 工作过程.md 23KB
Android R startActivity 流程(一) client发送启动请求.md 19KB
线程创建.md 18KB
HAL基础数据结构与模块加载.md 16KB
创建hidl项目.md 16KB
art虚拟机启动流程.md 15KB
Android R PointerEventDispatcher 触摸事件监听帮助类.md 15KB
Watchdog(3) monitor实现.md 7KB
Watchdog(1) 启动.md 7KB
README.ueventd.md 6KB
Android coredump解析与常用命令.md 6KB
常用命令.md 5KB
binder调试方法.md 5KB
README-R.md 4KB
Android10 启动activity event事件.md 2KB
Protolog启动关闭.md 2KB
Cpp IBinder 类关系图.mdj 73KB
input reader.mdj 71KB
ref - InputChannel通信架构.png 147KB
native crash框架概述图.png 124KB
JavaStacksDump流程.png 121KB
WMS与SurfaceFlinger通信架构图.png 58KB
WindowManager, ViewRootImpl, WIndowManagerService之间的关系.png 34KB
wms添加window概图.png 31KB
Window与WindowManager继承体系.png 20KB
WIndowManagerService继承体系.png 13KB
vendor.unique.smartpa@1.0-impl.so.rsp 466B
vendor.unique.smartpa@1.0-adapter-helper.a.rsp 319B
vendor.unique.smartpa@1.0-adapter-helper.a.rsp 309B
vendor.unique.smartpa@1.0-vts.profiler.a.rsp 308B
共 126 条
- 1
- 2
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6654
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功