在service.cpp中的Start()调用ExpandArgsAndExecv()
system/core/init/service.cpp
static bool ExpandArgsAndExecv(const std::vector<std::string>& args) { std::vector<std::string> expanded_args; std::vector<char*> c_strings; expanded_args.resize(args.size()); c_strings.push_back(const_cast<char*>(args[0].data())); for (std::size_t i = 1; i < args.size(); ++i) { if (!expand_props(args[i], &expanded_args[i])) { LOG(FATAL) << args[0] << ": cannot expand '" << args[i] << "'"; } c_strings.push_back(expanded_args[i].data()); } c_strings.push_back(nullptr); return execv(c_strings[0], c_strings.data()) == 0; }
以下面的reboot service为例,ExpandArgsAndExecv()函数args参数为:
/system/bin/sh /system/bin/recovery_test.sh
# service for reboot service reboot /system/bin/sh /system/bin/recovery_test.sh class core console oneshot group system audio drmrpc