summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2018-05-08 11:21:37 -0700
committerSteven Moreland <smoreland@google.com>2018-05-08 14:26:22 -0700
commit612d7a47bd2aea662b8077bf24761d07e7a1ceff (patch)
tree8b303ca777ae00f2988723dcb7eef9c720d926ec /init/builtins.cpp
parenta6a266af0038c13dfc8fd55bc4c902a60952fb24 (diff)
builtins: interface_{start, stop, restart}
e.x.: interface_start android.hardware.nfc@1.0/default onrestart interface_restart android.hardware.nfc@1.0/default Fixes: 79418581 Test: add this to a service, and killing that service, light is restarted onrestart interface_restart android.hardware.light@2.0::ILight/default Change-Id: Ia7ac9380f01038752325cfbe030df1dd4a5665e2
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 8bd92ccdd..17d34e134 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -240,6 +240,29 @@ static Result<Success> do_insmod(const BuiltinArguments& args) {
return Success();
}
+static Result<Success> do_interface_restart(const BuiltinArguments& args) {
+ Service* svc = ServiceList::GetInstance().FindInterface(args[1]);
+ if (!svc) return Error() << "interface " << args[1] << " not found";
+ svc->Restart();
+ return Success();
+}
+
+static Result<Success> do_interface_start(const BuiltinArguments& args) {
+ Service* svc = ServiceList::GetInstance().FindInterface(args[1]);
+ if (!svc) return Error() << "interface " << args[1] << " not found";
+ if (auto result = svc->Start(); !result) {
+ return Error() << "Could not start interface: " << result.error();
+ }
+ return Success();
+}
+
+static Result<Success> do_interface_stop(const BuiltinArguments& args) {
+ Service* svc = ServiceList::GetInstance().FindInterface(args[1]);
+ if (!svc) return Error() << "interface " << args[1] << " not found";
+ svc->Stop();
+ return Success();
+}
+
// mkdir <path> [mode] [owner] [group]
static Result<Success> do_mkdir(const BuiltinArguments& args) {
mode_t mode = 0755;
@@ -1050,6 +1073,9 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"init_user0", {0, 0, {false, do_init_user0}}},
{"insmod", {1, kMax, {true, do_insmod}}},
{"installkey", {1, 1, {false, do_installkey}}},
+ {"interface_restart", {1, 1, {false, do_interface_restart}}},
+ {"interface_start", {1, 1, {false, do_interface_start}}},
+ {"interface_stop", {1, 1, {false, do_interface_stop}}},
{"load_persist_props", {0, 0, {false, do_load_persist_props}}},
{"load_system_props", {0, 0, {false, do_load_system_props}}},
{"loglevel", {1, 1, {false, do_loglevel}}},