Commit dbfe98e5 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arcvm: Only expand ro.* properties

This will prevent Chrome from adding 'import' lines in the future
which could cause a infinite import loop (by importing the combined
property file itself.) See crbug.com/1114279.

This makes our unit tests simpler too.

BUG=None
TEST=arc.Boot.vm, try

Change-Id: I66f58cf4fdce5e2e84de754755e9d90525eb666e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343505Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796583}
parent 4747028d
...@@ -52,10 +52,6 @@ constexpr char kDalvikVmIsaArm64[] = "ro.dalvik.vm.isa.arm64=x86_64"; ...@@ -52,10 +52,6 @@ constexpr char kDalvikVmIsaArm64[] = "ro.dalvik.vm.isa.arm64=x86_64";
// Maximum length of an Android property value. // Maximum length of an Android property value.
constexpr int kAndroidMaxPropertyLength = 91; constexpr int kAndroidMaxPropertyLength = 91;
// The following 4 functions as well as the constants above are the _exact_ copy
// of the ones in platform2/arc/setup/arc_setup_util.cc. After modifying code in
// Chromium, make sure to reflect the changes to the platform2 side.
bool FindProperty(const std::string& line_prefix_to_find, bool FindProperty(const std::string& line_prefix_to_find,
std::string* out_prop, std::string* out_prop,
const std::string& line) { const std::string& line) {
...@@ -155,6 +151,12 @@ std::string ComputeOEMKey(brillo::CrosConfigInterface* config, ...@@ -155,6 +151,12 @@ std::string ComputeOEMKey(brillo::CrosConfigInterface* config,
return board; return board;
} }
bool IsComment(const std::string& line) {
return base::StartsWith(
base::TrimWhitespaceASCII(line, base::TrimPositions::TRIM_LEADING), "#",
base::CompareCase::SENSITIVE);
}
bool ExpandPropertyContents(const std::string& content, bool ExpandPropertyContents(const std::string& content,
brillo::CrosConfigInterface* config, brillo::CrosConfigInterface* config,
std::string* expanded_content, std::string* expanded_content,
...@@ -165,6 +167,16 @@ bool ExpandPropertyContents(const std::string& content, ...@@ -165,6 +167,16 @@ bool ExpandPropertyContents(const std::string& content,
std::string new_properties; std::string new_properties;
for (std::string line : lines) { for (std::string line : lines) {
// Chrome only expands ro. properties at runtime.
if (!base::StartsWith(line, "ro.", base::CompareCase::SENSITIVE)) {
if (!IsComment(line) && line.find('{') != std::string::npos) {
// The non-ro property has substitution(s).
LOG(ERROR) << "Found substitution(s) in a non-ro property: " << line;
return false;
}
continue;
}
// First expand {property} substitutions in the string. The insertions // First expand {property} substitutions in the string. The insertions
// may contain substitutions of their own, so we need to repeat until // may contain substitutions of their own, so we need to repeat until
// nothing more is found. // nothing more is found.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment