diff options
author | Martijn Coenen <maco@google.com> | 2019-05-15 22:04:13 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2019-05-15 22:23:41 +0200 |
commit | ebce675b177f22a3248b1104b21c9c79937b8fda (patch) | |
tree | b346993774400301470281be2c6621340d469dbc /init/builtins.cpp | |
parent | 122bf2aedffe3bdd9918b84c8a2ac2804d3c8fd8 (diff) | |
download | system_core-ebce675b177f22a3248b1104b21c9c79937b8fda.tar.gz system_core-ebce675b177f22a3248b1104b21c9c79937b8fda.tar.bz2 system_core-ebce675b177f22a3248b1104b21c9c79937b8fda.zip |
class_start_post_data also starts disabled services.
This keyword was introduced to support restarting services on devices
using APEX and FDE. The current implementation is not a restart, but
rather a 'reset' followed by a 'start', because the real /data must be
mounted in-between those two actions. But we effectively want this to be
a restart, which means that we also want to start 'disabled' services
that were running at the time we called 'class_reset_post_data'.
To implement this, keep track of whether a service was running when its
class was reset at post-data, and start all those services.
Bug: 132592548
Test: manual testing on FDE Taimen
Change-Id: I1e81e2c8e0ab2782150073d74e50e4cd734af7b9
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 34f229b7f..25f324ce5 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -104,35 +104,36 @@ static void ForEachServiceInClass(const std::string& classname, F function) { } } -static Result<Success> class_start(const std::string& class_name, bool post_data_only) { +static Result<Success> do_class_start(const BuiltinArguments& args) { // Do not start a class if it has a property persist.dont_start_class.CLASS set to 1. - if (android::base::GetBoolProperty("persist.init.dont_start_class." + class_name, false)) + if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false)) return Success(); // Starting a class does not start services which are explicitly disabled. // They must be started individually. for (const auto& service : ServiceList::GetInstance()) { - if (service->classnames().count(class_name)) { - if (post_data_only && !service->is_post_data()) { - continue; - } + if (service->classnames().count(args[1])) { if (auto result = service->StartIfNotDisabled(); !result) { LOG(ERROR) << "Could not start service '" << service->name() - << "' as part of class '" << class_name << "': " << result.error(); + << "' as part of class '" << args[1] << "': " << result.error(); } } } return Success(); } -static Result<Success> do_class_start(const BuiltinArguments& args) { - return class_start(args[1], false /* post_data_only */); -} - static Result<Success> do_class_start_post_data(const BuiltinArguments& args) { if (args.context != kInitContext) { return Error() << "command 'class_start_post_data' only available in init context"; } - return class_start(args[1], true /* post_data_only */); + for (const auto& service : ServiceList::GetInstance()) { + if (service->classnames().count(args[1])) { + if (auto result = service->StartIfPostData(); !result) { + LOG(ERROR) << "Could not start service '" << service->name() + << "' as part of class '" << args[1] << "': " << result.error(); + } + } + } + return Success(); } static Result<Success> do_class_stop(const BuiltinArguments& args) { |