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
(cherry picked from commit a185252c8e6d624587bc3d17f005cc122bda6cf7)
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 0661917..a53ccc0 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -855,20 +855,22 @@
}
string TWFunc::System_Property_Get(string Prop_Name) {
- return System_Property_Get(Prop_Name, PartitionManager, PartitionManager.Get_Android_Root_Path());
+ return System_Property_Get(Prop_Name, PartitionManager, PartitionManager.Get_Android_Root_Path(), "");
}
-string TWFunc::System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point) {
+string TWFunc::System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point, string prop_file_name) {
bool mount_state = PartitionManager.Is_Mounted_By_Path(Mount_Point);
std::vector<string> buildprop;
string propvalue;
if (!PartitionManager.Mount_By_Path(Mount_Point, true))
return propvalue;
- string prop_file = Mount_Point + "/build.prop";
- if (!TWFunc::Path_Exists(prop_file))
- prop_file = Mount_Point + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
+ string prop_file = Mount_Point + "/system/" + prop_file_name;
+ if (!TWFunc::Path_Exists(prop_file)) {
+ LOGINFO("Unable to locate file: %s\n", prop_file.c_str());
+ return propvalue;
+ }
if (TWFunc::read_file(prop_file, buildprop) != 0) {
- LOGINFO("Unable to open build.prop for getting '%s'.\n", Prop_Name.c_str());
+ LOGINFO("Unable to open %s for getting '%s'.\n", prop_file_name.c_str(), Prop_Name.c_str());
DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date());
if (!mount_state)
PartitionManager.UnMount_By_Path(Mount_Point, false);