init: Create classes for Action and Command
This creates the concept of 'event_trigger' vs 'property_trigger'
Previously these were merged into one, such that 'on property:a=b &&
property:b=c' is triggered when properties a=b and b=c as expected,
however combinations such as 'on early-boot && boot' would trigger
during both early-boot and boot. Similarly, 'on early-boot &&
property:a=b' would trigger on both early-boot and again when property
a equals b.
The event trigger distinction ensures that the first example fails to
parse and the second example only triggers on early-boot if
property a equals b.
This coalesces Actions with the same triggers into a single Action object
Change-Id: I8f661d96e8a2d40236f252301bfe10979d663ea6
diff --git a/init/signal_handler.cpp b/init/signal_handler.cpp
index 6893163..5a875bb 100644
--- a/init/signal_handler.cpp
+++ b/init/signal_handler.cpp
@@ -28,6 +28,7 @@
#include <cutils/list.h>
#include <cutils/sockets.h>
+#include "action.h"
#include "init.h"
#include "log.h"
#include "util.h"
@@ -133,18 +134,8 @@
svc->flags |= SVC_RESTARTING;
// Execute all onrestart commands for this service.
- struct listnode* node;
- list_for_each(node, &svc->onrestart.commands) {
- command* cmd = node_to_item(node, struct command, clist);
- std::vector<std::string> arg_strs;
- if (expand_command_arguments(cmd->nargs, cmd->args, &arg_strs)) {
- std::vector<char*> args;
- for (auto& s : arg_strs) {
- args.push_back(&s[0]);
- }
- cmd->func(args.size(), &args[0]);
- }
- }
+ svc->onrestart->ExecuteAllCommands();
+
svc->NotifyStateChange("restarting");
return true;
}