Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca00b0ed authored by Daniel Rosenberg's avatar Daniel Rosenberg
Browse files

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
parent 010a85af
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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();
}