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

Commit bc3ec37d authored by Jooyung Han's avatar Jooyung Han Committed by Automerger Merge Worker
Browse files

APEX configs support 'on' as well am: badb7de1

parents 1cbab9e1 badb7de1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@
#include <variant>
#include <vector>

#include <android-base/strings.h>

#include "builtins.h"
#include "keyword_map.h"
#include "result.h"
@@ -79,6 +81,7 @@ class Action {
    static void set_function_map(const BuiltinFunctionMap* function_map) {
        function_map_ = function_map;
    }
    bool IsFromApex() const { return base::StartsWith(filename_, "/apex/"); }

  private:
    void ExecuteCommand(const Command& command) const;
+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ class ActionManager {
    size_t CheckAllCommands();

    void AddAction(std::unique_ptr<Action> action);
    template <class UnaryPredicate>
    void RemoveActionIf(UnaryPredicate predicate) {
        actions_.erase(std::remove_if(actions_.begin(), actions_.end(), predicate), actions_.end());
    }
    void QueueEventTrigger(const std::string& trigger);
    void QueuePropertyChange(const std::string& name, const std::string& value);
    void QueueAllPropertyActions();
+2 −1
Original line number Diff line number Diff line
@@ -1288,7 +1288,8 @@ static Result<void> parse_apex_configs() {
        return Error() << "glob pattern '" << glob_pattern << "' failed";
    }
    std::vector<std::string> configs;
    Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance(), true);
    Parser parser =
            CreateApexConfigParser(ActionManager::GetInstance(), ServiceList::GetInstance());
    for (size_t i = 0; i < glob_result.gl_pathc; i++) {
        std::string path = glob_result.gl_pathv[i];
        // Filter-out /apex/<name>@<ver> paths. The paths are bind-mounted to
+5 −3
Original line number Diff line number Diff line
@@ -293,13 +293,15 @@ Parser CreateParser(ActionManager& action_manager, ServiceList& service_list) {
    return parser;
}

// parser that only accepts new services
Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex) {
// Returns a Parser that accepts scripts from APEX modules. It supports `service` and `on`.
Parser CreateApexConfigParser(ActionManager& action_manager, ServiceList& service_list) {
    Parser parser;

    parser.AddSectionParser(
            "service", std::make_unique<ServiceParser>(&service_list, GetSubcontext(), std::nullopt,
                                                       from_apex));
                                                       /*from_apex=*/true));
    parser.AddSectionParser("on", std::make_unique<ActionParser>(&action_manager, GetSubcontext()));

    return parser;
}

+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ namespace android {
namespace init {

Parser CreateParser(ActionManager& action_manager, ServiceList& service_list);
Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex);
Parser CreateApexConfigParser(ActionManager& action_manager, ServiceList& service_list);

bool start_waiting_for_property(const char *name, const char *value);

Loading