From 9d6feb53115e2dcc49a644400da4d62a16c1c3c6 Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Fri, 27 Jul 2018 10:05:24 -0400 Subject: twrp: use ANDROID_ROOT environment variable instead of hard-coded /system path I updated most of the references I found, but there might be more For devices that have to mount system at /system_root, this allows system to be bind mounted to /system and detected properly by TWRP Change-Id: I9f142fd8cec392f5b88e95476258dab9c21a9aac --- twrp-functions.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'twrp-functions.cpp') diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 40205c943..263593420 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -407,7 +407,7 @@ string TWFunc::Get_Root_Path(const string& Path) { void TWFunc::install_htc_dumlock(void) { int need_libs = 0; - if (!PartitionManager.Mount_By_Path("/system", true)) + if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) return; if (!PartitionManager.Mount_By_Path("/data", true)) @@ -809,19 +809,19 @@ string TWFunc::Get_Current_Date() { } string TWFunc::System_Property_Get(string Prop_Name) { - bool mount_state = PartitionManager.Is_Mounted_By_Path("/system"); + bool mount_state = PartitionManager.Is_Mounted_By_Path(PartitionManager.Get_Android_Root_Path()); std::vector buildprop; string propvalue; - if (!PartitionManager.Mount_By_Path("/system", true)) + if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) return propvalue; string prop_file = "/system/build.prop"; if (!TWFunc::Path_Exists(prop_file)) - prop_file = "/system/system/build.prop"; // for devices with system as a root file system (e.g. Pixel) + prop_file = PartitionManager.Get_Android_Root_Path() + "/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 /system/build.prop for getting '%s'.\n", Prop_Name.c_str()); + 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("/system", false); + PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false); return propvalue; } int line_count = buildprop.size(); @@ -834,12 +834,12 @@ string TWFunc::System_Property_Get(string Prop_Name) { if (propname == Prop_Name) { propvalue = buildprop.at(index).substr(end_pos + 1, buildprop.at(index).size()); if (!mount_state) - PartitionManager.UnMount_By_Path("/system", false); + PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false); return propvalue; } } if (!mount_state) - PartitionManager.UnMount_By_Path("/system", false); + PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false); return propvalue; } @@ -1095,14 +1095,14 @@ std::string TWFunc::to_string(unsigned long value) { } void TWFunc::Disable_Stock_Recovery_Replace(void) { - if (PartitionManager.Mount_By_Path("/system", false)) { + if (PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), false)) { // Disable flashing of stock recovery if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) { rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak"); gui_msg("rename_stock=Renamed stock recovery file in /system to prevent the stock ROM from replacing TWRP."); sync(); } - PartitionManager.UnMount_By_Path("/system", false); + PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false); } } -- cgit v1.2.3