Add optional PartitionManager and Mount_Point to
Get_System_Properties for use during SAR-detect
Change-Id: Ie1ffba53459b7bb77ca47d9cb928b2626c704a05
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 40d0549..97387b7 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -895,19 +895,23 @@
}
string TWFunc::System_Property_Get(string Prop_Name) {
- bool mount_state = PartitionManager.Is_Mounted_By_Path(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) {
+ bool mount_state = PartitionManager.Is_Mounted_By_Path(Mount_Point);
std::vector<string> buildprop;
string propvalue;
- if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true))
+ if (!PartitionManager.Mount_By_Path(Mount_Point, true))
return propvalue;
- string prop_file = "/system/build.prop";
+ string prop_file = Mount_Point + "/build.prop";
if (!TWFunc::Path_Exists(prop_file))
- prop_file = PartitionManager.Get_Android_Root_Path() + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
+ prop_file = Mount_Point + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
if (TWFunc::read_file(prop_file, buildprop) != 0) {
LOGINFO("Unable to open build.prop for getting '%s'.\n", Prop_Name.c_str());
DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date());
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}
int line_count = buildprop.size();
@@ -920,12 +924,12 @@
if (propname == Prop_Name) {
propvalue = buildprop.at(index).substr(end_pos + 1, buildprop.at(index).size());
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}
}
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}