TW_OVERRIDE_SYSTEM_PROPS: move to after super partition is set up

Change-Id: I288ef00752be0cf59977e80007a9d2e0a059b41d
diff --git a/twrp.cpp b/twrp.cpp
index a6b0faa..4a6a8b8 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -179,33 +179,6 @@
 				property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
 			}
 
-// We are doing this here during SAR-detection, since we are mounting the system-partition anyway
-// This way we don't need to remount it later, just for overriding properties
-#if defined(TW_INCLUDE_LIBRESETPROP) && defined(TW_OVERRIDE_SYSTEM_PROPS)
-			stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS));
-			string current_prop;
-			while (getline(override_props, current_prop, ';')) {
-				string other_prop;
-				if (current_prop.find("=") != string::npos) {
-					other_prop = current_prop.substr(current_prop.find("=") + 1);
-					current_prop = current_prop.substr(0, current_prop.find("="));
-				} else {
-					other_prop = current_prop;
-				}
-				other_prop = android::base::Trim(other_prop);
-				current_prop = android::base::Trim(current_prop);
-				string sys_val = TWFunc::System_Property_Get(other_prop, SarPartitionManager, "/s");
-				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);
-					}
-				} else {
-					LOGINFO("Not overriding %s with empty value from system property %s\n", current_prop.c_str(), other_prop.c_str());
-				}
-			}
-#endif
 			SarPartitionManager.UnMount_By_Path("/s", false);
 		} else {
 			LOGINFO("SAR-DETECT: Could not mount system partition, falling back to %s\n", fallback_sar ? "SAR":"Non-SAR");
@@ -444,6 +417,37 @@
 		}
 	}
 #endif
+// We are doing this here to allow super partition to be set up prior to overriding properties
+#if defined(TW_INCLUDE_LIBRESETPROP) && defined(TW_OVERRIDE_SYSTEM_PROPS)
+	if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) {
+		LOGERR("Unable to mount %s\n", PartitionManager.Get_Android_Root_Path().c_str());
+	} else {
+		stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS));
+		string current_prop;
+		while (getline(override_props, current_prop, ';')) {
+			string other_prop;
+			if (current_prop.find("=") != string::npos) {
+				other_prop = current_prop.substr(current_prop.find("=") + 1);
+				current_prop = current_prop.substr(0, current_prop.find("="));
+			} else {
+				other_prop = current_prop;
+			}
+			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);
+				}
+			} 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);
+	}
+#endif
 
 	twrpAdbBuFifo *adb_bu_fifo = new twrpAdbBuFifo();
 	adb_bu_fifo->threadAdbBuFifo();