summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-04-12 15:38:27 -0700
committerElliott Hughes <enh@google.com>2016-04-12 15:38:51 -0700
commita3cc6026301db08285028c760af2665a66b3cc44 (patch)
tree0fbaf980e3e077ffd0a6b4b9f58ff108fb0c1fa0
parente3a3288dddcde8c180dfe2935335ca3c475e37a2 (diff)
Remove undocumented functionality from init.
Bug: http://b/28151340 Change-Id: I5360502c79d9113a13055bf017b39c099033e947
-rw-r--r--init/init.cpp52
-rw-r--r--init/service.cpp17
-rw-r--r--init/service.h1
3 files changed, 7 insertions, 63 deletions
diff --git a/init/init.cpp b/init/init.cpp
index 0ff55a599..84da2b956 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -141,59 +141,19 @@ static void restart_processes()
});
}
-static void msg_start(const std::string& name)
-{
- Service* svc = nullptr;
- std::vector<std::string> vargs;
-
- size_t colon_pos = name.find(':');
- if (colon_pos == std::string::npos) {
- svc = ServiceManager::GetInstance().FindServiceByName(name);
- } else {
- std::string service_name(name.substr(0, colon_pos));
- std::string args(name.substr(colon_pos + 1));
- vargs = android::base::Split(args, " ");
-
- svc = ServiceManager::GetInstance().FindServiceByName(service_name);
- }
-
- if (svc) {
- svc->Start(vargs);
- } else {
- ERROR("no such service '%s'\n", name.c_str());
- }
-}
-
-static void msg_stop(const std::string& name)
-{
+void handle_control_message(const std::string& msg, const std::string& name) {
Service* svc = ServiceManager::GetInstance().FindServiceByName(name);
-
- if (svc) {
- svc->Stop();
- } else {
- ERROR("no such service '%s'\n", name.c_str());
- }
-}
-
-static void msg_restart(const std::string& name)
-{
- Service* svc = ServiceManager::GetInstance().FindServiceByName(name);
-
- if (svc) {
- svc->Restart();
- } else {
+ if (svc == nullptr) {
ERROR("no such service '%s'\n", name.c_str());
+ return;
}
-}
-void handle_control_message(const std::string& msg, const std::string& arg)
-{
if (msg == "start") {
- msg_start(arg);
+ svc->Start();
} else if (msg == "stop") {
- msg_stop(arg);
+ svc->Stop();
} else if (msg == "restart") {
- msg_restart(arg);
+ svc->Restart();
} else {
ERROR("unknown control msg '%s'\n", msg.c_str());
}
diff --git a/init/service.cpp b/init/service.cpp
index bdecc324f..f1ffa189f 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -315,7 +315,7 @@ bool Service::HandleLine(const std::vector<std::string>& args, std::string* err)
return (this->*handler)(args, err);
}
-bool Service::Start(const std::vector<std::string>& dynamic_args) {
+bool Service::Start() {
// Starting a service removes it from the disabled or reset state and
// immediately takes it out of the restarting state if it was in there.
flags_ &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET|SVC_RESTART|SVC_DISABLED_START));
@@ -343,13 +343,6 @@ bool Service::Start(const std::vector<std::string>& dynamic_args) {
return false;
}
- if ((!(flags_ & SVC_ONESHOT)) && !dynamic_args.empty()) {
- ERROR("service '%s' must be one-shot to use dynamic args, disabling\n",
- args_[0].c_str());
- flags_ |= SVC_DISABLED;
- return false;
- }
-
std::string scon;
if (!seclabel_.empty()) {
scon = seclabel_;
@@ -471,9 +464,6 @@ bool Service::Start(const std::vector<std::string>& dynamic_args) {
for (const auto& s : args_) {
strs.push_back(const_cast<char*>(s.c_str()));
}
- for (const auto& s : dynamic_args) {
- strs.push_back(const_cast<char*>(s.c_str()));
- }
strs.push_back(nullptr);
if (execve(args_[0].c_str(), (char**) &strs[0], (char**) ENV) < 0) {
ERROR("cannot execve('%s'): %s\n", args_[0].c_str(), strerror(errno));
@@ -502,11 +492,6 @@ bool Service::Start(const std::vector<std::string>& dynamic_args) {
return true;
}
-bool Service::Start() {
- const std::vector<std::string> null_dynamic_args;
- return Start(null_dynamic_args);
-}
-
bool Service::StartIfNotDisabled() {
if (!(flags_ & SVC_DISABLED)) {
return Start();
diff --git a/init/service.h b/init/service.h
index 35abde9b7..d9d18efb1 100644
--- a/init/service.h
+++ b/init/service.h
@@ -76,7 +76,6 @@ public:
const std::string& seclabel, const std::vector<std::string>& args);
bool HandleLine(const std::vector<std::string>& args, std::string* err);
- bool Start(const std::vector<std::string>& dynamic_args);
bool Start();
bool StartIfNotDisabled();
bool Enable();