diff options
| author | Daniel Norman <danielnorman@google.com> | 2022-03-09 10:49:26 -0800 |
|---|---|---|
| committer | Daniel Norman <danielnorman@google.com> | 2022-03-21 15:45:44 -0700 |
| commit | 3b44ff76f9bf976a8d9fe0aadcbe2613f98760ff (patch) | |
| tree | 01e52bfd3694f99137e0a6334ab66b11f14ad70a /init/builtins.cpp | |
| parent | 599e82418fd7af4e87b13309f9e2c52d149c731b (diff) | |
Adds an init host lib for use in host_apex_verifier.
Includes extracting the APEX-specific SDK version naming scheme filter
logic so it can be reused when host_apex_verifier looks at rc files
inside the APEX.
Bug: 222121216
Test: Use in host_apex_verifier
Change-Id: I0396a455f30d2de71525ccd3fa69c75576054048
Diffstat (limited to 'init/builtins.cpp')
| -rw-r--r-- | init/builtins.cpp | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 0eb894bec5..01db4f5dab 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -1306,58 +1306,11 @@ static Result<void> parse_apex_configs() { } globfree(&glob_result); - // Compare all files /apex/path.#rc and /apex/path.rc with the same "/apex/path" prefix, - // choosing the one with the highest # that doesn't exceed the system's SDK. - // (.rc == .0rc for ranking purposes) - // int active_sdk = android::base::GetIntProperty("ro.build.version.sdk", INT_MAX); - std::map<std::string, std::pair<std::string, int>> script_map; - - for (const auto& c : configs) { - int sdk = 0; - const std::vector<std::string> parts = android::base::Split(c, "."); - std::string base; - if (parts.size() < 2) { - continue; - } - - // parts[size()-1], aka the suffix, should be "rc" or "#rc" - // any other pattern gets discarded - - const auto& suffix = parts[parts.size() - 1]; - if (suffix == "rc") { - sdk = 0; - } else { - char trailer[9] = {0}; - int r = sscanf(suffix.c_str(), "%d%8s", &sdk, trailer); - if (r != 2) { - continue; - } - if (strlen(trailer) > 2 || strcmp(trailer, "rc") != 0) { - continue; - } - } - - if (sdk < 0 || sdk > active_sdk) { - continue; - } - - base = parts[0]; - for (unsigned int i = 1; i < parts.size() - 1; i++) { - base = base + "." + parts[i]; - } - - // is this preferred over what we already have - auto it = script_map.find(base); - if (it == script_map.end() || it->second.second < sdk) { - script_map[base] = std::make_pair(c, sdk); - } - } - bool success = true; - for (const auto& m : script_map) { - success &= parser.ParseConfigFile(m.second.first); + for (const auto& c : parser.FilterVersionedConfigs(configs, active_sdk)) { + success &= parser.ParseConfigFile(c); } ServiceList::GetInstance().MarkServicesUpdate(); if (success) { |
