1. Set Device Permissions during init
The init executable file is the first user space program run by the Android system. It runs as a daemon.
2. Content in init. RC
Use the startup script init. RC, init STARTUP script path: System/CORE/rootdir/init. RC can perform some simple initialization operations during system initialization, init. the RC Script is directly installed in the root file system of the target system and parsed by the init executable program.
Init. RC is a STARTUP script executed after init is started. Its Syntax mainly includes the following:
Commands: Command
Actions: Action
Triggers: triggers
Services: Service
Options: Options
Properties: Properties
For the keyword of the init script, refer to the system/CORE/init/keyword. h file of the INIT process.
Commands: commands are some basic operations.
Export path/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
Mount yaffs2 MTD @ system/System
Mount yaffs2 MTD @ system/system Ro remount
Mount yaffs2 MTD @ userdata/Data nosuid nodev
Mount yaffs2 MTD @ Cache/cache nosuid nodev
These commands are parsed In the init executable program, and then relevant functions are called for implementation.
Actions: Action, which indicates a series of commands. It is usually called in triggers trigger conditions, and the form of action and trigger conditions.
On <trigger>
<Command>
On init
Export path/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
Init indicates a trigger condition initialization process. After this trigger event occurs, setting environment variables and creating directories is called an action.
The properties attribute is some values used in the system and can be set and read.
In the startup script, attributes are used as follows:
Setprop Ro. foreground_app_mem 2048
Setprop Ro. visible_app_mem 3072
On Property: RO. Secure = 0
Start Console
On property can be used to determine attributes. The attributes here are consistent throughout the Android system.
Services Service, which usually starts an executable program. The options option is the additional content of the service, used in combination with the service.
For example, start the phone process RIL-daemon and boot animation services.
Service RIL-daemon/system/bin/rild
Socket rild stream 660 root radio
Socket rild-Debug stream 660 Radio System
User Root
Group radio cache Inet MISC audio sdcard_rw
Service bootanim/system/bin/bootanimation
User graphics
Group graphics
Disabled
Oneshot
RIL-daemon and bootaim indicate the service name,/system/bin/rild and system/bin/bootanimation indicate the path of the executable program to be executed by the Service.
The oneshot option indicates that the service is started only once. If the oneshot option is not available, the executable program will always exist. If the executable program is killed, it will be restarted, RIL-daemon is a daemon. If it exits, it needs to be restarted. Therefore, it does not use the oneshot; bootaim boot animation, which is executed only once. Therefore, oneshot is added.