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
This commit is contained in:
parent
010a85afe5
commit
ca00b0edeb
1 changed files with 6 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue