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/service.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/service.cpp')
-rw-r--r-- | init/service.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/init/service.cpp b/init/service.cpp index 2f9668107..ccc37b70c 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -1154,10 +1154,23 @@ void Service::Reset() { void Service::ResetIfPostData() { if (post_data_) { + if (flags_ & SVC_RUNNING) { + running_at_post_data_reset_ = true; + } StopOrReset(SVC_RESET); } } +Result<Success> Service::StartIfPostData() { + // Start the service, but only if it was started after /data was mounted, + // and it was still running when we reset the post-data services. + if (running_at_post_data_reset_) { + return Start(); + } + + return Success(); +} + void Service::Stop() { StopOrReset(SVC_DISABLED); } |