您的位置:首页 > 其它

init.rc 状态服务器相关语法分析

2011-12-08 01:00 351 查看
状态服务器相关:

在init.c 的main函数中启动状态服务器。

property_set_fd = start_property_service();

状态读取函数:

Property_service.c (system\core\init)

const char* property_get(const char *name)

Properties.c (system\core\libcutils)

int property_get(const char *key, char *value, const char *default_value)

状态设置函数:

Property_service.c (system\core\init)

int property_set(const char *name, const char *value)

Properties.c (system\core\libcutils)

int property_set(const char *key, const char *value)

在终端模式下我们可以通过执行命令 setprop <key> <value>

setprop 工具源代码所在文件: Setprop.c (system\core\toolbox)

Getprop.c (system\core\toolbox): property_get(argv[1], value, default_value);

Property_service.c (system\core\init)

中定义的状态读取和设置函数仅供init进程调用,

handle_property_set_fd(property_set_fd);

property_set() //Property_service.c (system\core\init)

property_changed(name, value) //Init.c (system\core\init)

queue_property_triggers(name, value)

drain_action_queue()

只要属性一改变就会被触发,然后执行相应的命令:

例如:

在init.rc 文件中有

on property:persist.service.adb.enable=1

start adbd

on property:persist.service.adb.enable=0

stop adbd

所以如果在终端下输入:

setprop property:persist.service.adb.enable 1或者0

那么将会开启或者关闭adbd 程序。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: