init: remove the class_{start,reset}_post_data commands
Remove the class_start_post_data and class_reset_post_data commands,
since they aren't used anymore. They were only used on devices that
used FDE (Full Disk Encryption), via actions in rootdir/init.rc. These
actions have been removed, since support for FDE has been removed.
There is no use case for these commands in vendor init scripts either.
Keep the mark_post_data command, since DoUserspaceReboot() uses the
post-data service flag even on non-FDE devices.
Bug: 191796797
Change-Id: Ibcd97543daa724feb610546b5fc2a0dd7f1e62e7
diff --git a/init/README.md b/init/README.md
index 6c29b07..b10ca9e 100644
--- a/init/README.md
+++ b/init/README.md
@@ -487,11 +487,6 @@
not already running. See the start entry for more information on
starting services.
-`class_start_post_data <serviceclass>`
-> Like `class_start`, but only considers services that were started
- after /data was mounted, and that were running at the time
- `class_reset_post_data` was called. Only used for FDE devices.
-
`class_stop <serviceclass>`
> Stop and disable all services of the specified class if they are
currently running.
@@ -501,10 +496,6 @@
currently running, without disabling them. They can be restarted
later using `class_start`.
-`class_reset_post_data <serviceclass>`
-> Like `class_reset`, but only considers services that were started
- after /data was mounted. Only used for FDE devices.
-
`class_restart <serviceclass>`
> Restarts all services of the specified class.
@@ -607,8 +598,7 @@
Properties are expanded within _level_.
`mark_post_data`
-> Used to mark the point right after /data is mounted. Used to implement the
- `class_reset_post_data` and `class_start_post_data` commands.
+> Used to mark the point right after /data is mounted.
`mkdir <path> [<mode>] [<owner>] [<group>] [encryption=<action>] [key=<key>]`
> Create a directory at _path_, optionally with the given mode, owner, and
diff --git a/init/builtins.cpp b/init/builtins.cpp
index e9c717a..50a0cb2 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -46,7 +46,6 @@
#include <map>
#include <memory>
-#include <ApexProperties.sysprop.h>
#include <InitProperties.sysprop.h>
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
@@ -177,28 +176,6 @@
return {};
}
-static Result<void> do_class_start_post_data(const BuiltinArguments& args) {
- if (args.context != kInitContext) {
- return Error() << "command 'class_start_post_data' only available in init context";
- }
- static bool is_apex_updatable = android::sysprop::ApexProperties::updatable().value_or(false);
-
- if (!is_apex_updatable) {
- // No need to start these on devices that don't support APEX, since they're not
- // stopped either.
- return {};
- }
- for (const auto& service : ServiceList::GetInstance()) {
- if (service->classnames().count(args[1])) {
- if (auto result = service->StartIfPostData(); !result.ok()) {
- LOG(ERROR) << "Could not start service '" << service->name()
- << "' as part of class '" << args[1] << "': " << result.error();
- }
- }
- }
- return {};
-}
-
static Result<void> do_class_stop(const BuiltinArguments& args) {
ForEachServiceInClass(args[1], &Service::Stop);
return {};
@@ -209,19 +186,6 @@
return {};
}
-static Result<void> do_class_reset_post_data(const BuiltinArguments& args) {
- if (args.context != kInitContext) {
- return Error() << "command 'class_reset_post_data' only available in init context";
- }
- static bool is_apex_updatable = android::sysprop::ApexProperties::updatable().value_or(false);
- if (!is_apex_updatable) {
- // No need to stop these on devices that don't support APEX.
- return {};
- }
- ForEachServiceInClass(args[1], &Service::ResetIfPostData);
- return {};
-}
-
static Result<void> do_class_restart(const BuiltinArguments& args) {
// Do not restart a class if it has a property persist.dont_start_class.CLASS set to 1.
if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false))
@@ -1428,10 +1392,8 @@
{"chmod", {2, 2, {true, do_chmod}}},
{"chown", {2, 3, {true, do_chown}}},
{"class_reset", {1, 1, {false, do_class_reset}}},
- {"class_reset_post_data", {1, 1, {false, do_class_reset_post_data}}},
{"class_restart", {1, 1, {false, do_class_restart}}},
{"class_start", {1, 1, {false, do_class_start}}},
- {"class_start_post_data", {1, 1, {false, do_class_start_post_data}}},
{"class_stop", {1, 1, {false, do_class_stop}}},
{"copy", {2, 2, {true, do_copy}}},
{"copy_per_line", {2, 2, {true, do_copy_per_line}}},
diff --git a/init/service.cpp b/init/service.cpp
index 489dd67..f7318cb 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -661,25 +661,6 @@
StopOrReset(SVC_RESET);
}
-void Service::ResetIfPostData() {
- if (post_data_) {
- if (flags_ & SVC_RUNNING) {
- running_at_post_data_reset_ = true;
- }
- StopOrReset(SVC_RESET);
- }
-}
-
-Result<void> 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 {};
-}
-
void Service::Stop() {
StopOrReset(SVC_DISABLED);
}
diff --git a/init/service.h b/init/service.h
index ccf6899..3289f54 100644
--- a/init/service.h
+++ b/init/service.h
@@ -80,10 +80,8 @@
Result<void> ExecStart();
Result<void> Start();
Result<void> StartIfNotDisabled();
- Result<void> StartIfPostData();
Result<void> Enable();
void Reset();
- void ResetIfPostData();
void Stop();
void Terminate();
void Timeout();
@@ -214,8 +212,6 @@
bool post_data_ = false;
- bool running_at_post_data_reset_ = false;
-
std::optional<std::string> on_failure_reboot_target_;
bool from_apex_ = false;