实例演示
关闭和启动init.rc中的console 服务
service console /system/bin/sh
class core
console
disabled
user shell
group log
代码实现
shell :
setprop ctl.start service_name
setprop ctl.stop service_name
JNI:
property_set("ctl.start", service_name);
property_set("ctl.stop", service_name);
code位置:
systemcoreinitProperty_service.cpp
uint32_t HandlePropertySet(const std::string& name, const std::string& value, const std::string& source_context, const ucred& cr, std::string* error) { if (auto ret = CheckPermissions(name, value, source_context, cr, error); ret != PROP_SUCCESS) { return ret; } if (StartsWith(name, "ctl.")) { HandleControlMessage(name.c_str() + 4, value, cr.pid); return PROP_SUCCESS; }
权限
uid == AID_SYSTEM || uid == AID_ROOT
参见 system/core/init/property_service.c中check_control_perms函数
原文链接:https://blog.csdn.net/aeolia_zhang/article/details/20126031