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
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 5c8a437..da407fa 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1104,7 +1104,7 @@
}
}
TWFunc::GUI_Operation_Text(TW_UPDATE_SYSTEM_DETAILS_TEXT, gui_parse_text("{@updating_system_details}"));
- UnMount_By_Path("/system", false);
+ UnMount_By_Path(Get_Android_Root_Path(), false);
Update_System_Details();
UnMount_Main_Partitions();
time(&rStop);
@@ -1490,7 +1490,7 @@
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
(*iter)->Update_Size(true);
if ((*iter)->Can_Be_Mounted) {
- if ((*iter)->Mount_Point == "/system") {
+ if ((*iter)->Mount_Point == Get_Android_Root_Path()) {
int backup_display_size = (int)((*iter)->Backup_Size / 1048576LLU);
DataManager::SetValue(TW_BACKUP_SYSTEM_SIZE, backup_display_size);
} else if ((*iter)->Mount_Point == "/data" || (*iter)->Mount_Point == "/datadata") {
@@ -1859,7 +1859,7 @@
TWPartition* Boot_Partition = Find_Partition_By_Path("/boot");
- UnMount_By_Path("/system", true);
+ UnMount_By_Path(Get_Android_Root_Path(), true);
if (!datamedia)
UnMount_By_Path("/data", true);
@@ -2726,6 +2726,13 @@
return Active_Slot_Display;
}
+string TWPartitionManager::Get_Android_Root_Path() {
+ std::string Android_Root = getenv("ANDROID_ROOT");
+ if (Android_Root == "")
+ Android_Root = "/system";
+ return Android_Root;
+}
+
void TWPartitionManager::Remove_Uevent_Devices(const string& Mount_Point) {
std::vector<TWPartition*>::iterator iter;