summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2018-11-27 22:08:02 -0800
committerDaniel Rosenberg <drosen@google.com>2019-01-09 15:18:01 -0800
commitca00b0edebe888e55b068adaab30680d4c40becf (patch)
treef984fca1eaafac392190db1a68e246a968905e79 /init/builtins.cpp
parent010a85afe5783fa180d39bc0164ad76ac4de4675 (diff)
Add conditional class starting
This adds the ability to prevent a class from starting if a certain persistent property has been set to disallow it. A class will only load if there is not a property named persist.init.dont_start_class.[class name] set to 1. Test: Set a property called persist.dont_start_class.[class] to 1. Verify that the given class does not start Change-Id: I51c70ad635762ed77855d0509e630adb0aec0eb1
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 7fd4e2737..52828c00d 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -100,6 +100,9 @@ static void ForEachServiceInClass(const std::string& classname, F function) {
}
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." + 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()) {
@@ -124,6 +127,9 @@ static Result<Success> do_class_reset(const BuiltinArguments& args) {
}
static Result<Success> 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))
+ return Success();
ForEachServiceInClass(args[1], &Service::Restart);
return Success();
}