|
16 | 16 |
|
17 | 17 | #include "cuttlefish/host/libs/config/config_flag.h" |
18 | 18 |
|
| 19 | +#include <map> |
19 | 20 | #include <optional> |
20 | 21 | #include <ostream> |
21 | 22 | #include <set> |
|
36 | 37 | #include <json/value.h> |
37 | 38 | #include <json/writer.h> |
38 | 39 |
|
| 40 | +#include "cuttlefish/common/libs/key_equals_value/key_equals_value.h" |
39 | 41 | #include "cuttlefish/common/libs/utils/files.h" |
40 | 42 | #include "cuttlefish/common/libs/utils/flag_parser.h" |
41 | 43 | #include "cuttlefish/common/libs/utils/json.h" |
@@ -168,31 +170,21 @@ class ConfigFlagImpl : public ConfigFlag { |
168 | 170 | if(!ReadFileToString(info_path, &android_info)) { |
169 | 171 | return {}; |
170 | 172 | } |
171 | | - // grab the config with name "config" in android-info.txt, |
172 | | - // it's the setting that's respected. |
173 | | - // TODO (rammuthiah) Replace this logic with ParseMiscInfo |
174 | | - // from host/commands/assemble_cvd/misc_info.h |
175 | | - // Currently blocked on linking error for misc_info which is part of |
176 | | - // assemble_cvd and this bit of code which is in run_cvd. |
177 | | - auto split_config = Split(android_info, "\n"); |
178 | | - if (split_config.empty()) { |
| 173 | + Result<std::map<std::string, std::string>> parsed_config = |
| 174 | + ParseKeyEqualsValue(android_info); |
| 175 | + if (!parsed_config.ok()) { |
179 | 176 | return {}; |
180 | 177 | } |
181 | | - |
182 | | - for (std::string_view local_config_value : split_config) { |
183 | | - if (!android::base::ConsumePrefix(&local_config_value, "config=")) { |
184 | | - continue; |
185 | | - } |
186 | | - |
187 | | - if (!config_reader_.HasConfig(std::string{local_config_value})) { |
188 | | - LOG(WARNING) << info_path << " contains invalid config preset: '" |
189 | | - << local_config_value << "'."; |
190 | | - return {}; |
191 | | - } |
192 | | - return std::string{local_config_value}; |
| 178 | + auto config_it = parsed_config->find("config"); |
| 179 | + if (config_it == parsed_config->end()) { |
| 180 | + return {}; |
193 | 181 | } |
194 | | - |
195 | | - return {}; |
| 182 | + if (!config_reader_.HasConfig(config_it->second)) { |
| 183 | + LOG(WARNING) << info_path << " contains invalid config preset: '" |
| 184 | + << config_it->second << "'."; |
| 185 | + return {}; |
| 186 | + } |
| 187 | + return config_it->second; |
196 | 188 | } |
197 | 189 |
|
198 | 190 | ConfigReader& config_reader_; |
|
0 commit comments