System_Property_Get: Allow specifying multiple prop file paths
Some OEMs include prop files in custom locations. Add these to
a list and parse when setting properties.
Use the flag TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS followed
by a semi-colon-separated list of paths (relative to /system)
where the additional prop files can be found.
The standard build.prop file does not need to be specified and
will always be parsed.
Example:
TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS := etc/buildinfo/oem_build.prop;etc/prop.default
Change-Id: Ie0e25c7d2575d928310ff1b4fc1aef44a83784ca
diff --git a/twrp.cpp b/twrp.cpp
index aa09e2c..4a7a337 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -174,6 +174,11 @@
} else {
stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS));
string current_prop;
+ std::vector<std::string> build_prop_list = {"build.prop"};
+#ifdef TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS
+ std::vector<std::string> additional_build_prop_list = TWFunc::Split_String(TW_SYSTEM_BUILD_PROP_ADDITIONAL_PATHS, ";");
+ build_prop_list.insert(build_prop_list.end(), additional_build_prop_list.begin(), additional_build_prop_list.end());
+#endif
while (getline(override_props, current_prop, ';')) {
string other_prop;
if (current_prop.find("=") != string::npos) {
@@ -184,15 +189,19 @@
}
other_prop = android::base::Trim(other_prop);
current_prop = android::base::Trim(current_prop);
- string sys_val = TWFunc::System_Property_Get(other_prop, PartitionManager, PartitionManager.Get_Android_Root_Path().c_str());
- if (!sys_val.empty()) {
- LOGINFO("Overriding %s with value: \"%s\" from system property %s\n", current_prop.c_str(), sys_val.c_str(), other_prop.c_str());
- int error = TWFunc::Property_Override(current_prop, sys_val);
- if (error) {
- LOGERR("Failed overriding property %s, error_code: %d\n", current_prop.c_str(), error);
+
+ for (auto&& prop_file:build_prop_list) {
+ string sys_val = TWFunc::System_Property_Get(other_prop, PartitionManager, PartitionManager.Get_Android_Root_Path().c_str(), prop_file);
+ if (!sys_val.empty()) {
+ LOGINFO("Overriding %s with value: \"%s\" from system property %s from %s\n", current_prop.c_str(), sys_val.c_str(), other_prop.c_str(), prop_file.c_str());
+ int error = TWFunc::Property_Override(current_prop, sys_val);
+ if (error) {
+ LOGERR("Failed overriding property %s, error_code: %d\n", current_prop.c_str(), error);
+ }
+ break;
+ } else {
+ LOGINFO("Not overriding %s with empty value from system property %s from %s\n", current_prop.c_str(), other_prop.c_str(), prop_file.c_str());
}
- } else {
- LOGINFO("Not overriding %s with empty value from system property %s\n", current_prop.c_str(), other_prop.c_str());
}
}
PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);