Revert "Handle XML files format properly"

* Since I5c01045d6efef0b2ac497b40d78410c2b75d30d0 is added, RapidXML itself is able to determine ABX format.
* `TWFunc::System_Property_Get("ro.build.version.sdk").c_str()) > 30` makes it mount system partition.
* Some ROMs might have set 'persist.sys.binary_xml=false' to disable ABX XML format.

This reverts commit ee02585ea17ac6d32fe19395a9872f18176256d2.

Change-Id: I0f997f33aabced3a524d7ef09d9a5244bc9bd4aa
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index b87446b..e3d9a54 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1854,30 +1854,23 @@
 			user.userId = to_string(userId);
 
 			// Attempt to get name of user. Fallback to user ID if this fails.
-			std::string path = "/data/system/users/" + to_string(userId) + ".xml";
-			if ((atoi(TWFunc::System_Property_Get("ro.build.version.sdk").c_str()) > 30) && TWFunc::Path_Exists(path)) {
-				if(!TWFunc::Check_Xml_Format(path))
-					user.userName = to_string(userId);
+			char* userFile = PageManager::LoadFileToBuffer("/data/system/users/" + to_string(userId) + ".xml", NULL);
+			if (userFile == NULL) {
+				user.userName = to_string(userId);
 			}
 			else {
-				char* userFile = PageManager::LoadFileToBuffer(path, NULL);
-				if (userFile == NULL) {
+				xml_document<> *userXml = new xml_document<>();
+				userXml->parse<0>(userFile);
+				xml_node<>* userNode = userXml->first_node("user");
+				if (userNode == nullptr) {
 					user.userName = to_string(userId);
-				}
-				else {
-					xml_document<> *userXml = new xml_document<>();
-					userXml->parse<0>(userFile);
-					xml_node<>* userNode = userXml->first_node("user");
-					if (userNode == nullptr) {
+				} else {
+					xml_node<>* nameNode = userNode->first_node("name");
+					if (nameNode == nullptr)
 						user.userName = to_string(userId);
-					} else {
-						xml_node<>* nameNode = userNode->first_node("name");
-						if (nameNode == nullptr)
-							user.userName = to_string(userId);
-						else {
-							string userName = nameNode->value();
-							user.userName = userName + " (" + to_string(userId) + ")";
-						}
+					else {
+						string userName = nameNode->value();
+						user.userName = userName + " (" + to_string(userId) + ")";
 					}
 				}
 			}
@@ -3013,16 +3006,6 @@
 		LOGERR("Cannot decrypt adopted storage because /data will not mount\n");
 		return false;
 	}
-
-	// In Android 12 xml format changed. Previously it was human-readable format with xml tags
-	// now it's ABX (Android Binary Xml). Sadly, rapidxml can't parse it, so check xml format firstly
-	std::string path = "/data/system/storage.xml";
-	if ((atoi(TWFunc::System_Property_Get("ro.build.version.sdk").c_str()) > 30) && TWFunc::Path_Exists(path))
-		if(!TWFunc::Check_Xml_Format(path)) {
-			LOGINFO("Android 12+: storage.xml is in ABX format. Skipping adopted storage decryption\n");
-			return false;
-		}
-
 	LOGINFO("Decrypt adopted storage starting\n");
 	char* xmlFile = PageManager::LoadFileToBuffer("/data/system/storage.xml", NULL);
 	xml_document<> *doc = NULL;
@@ -3630,4 +3613,4 @@
 		return false;
 	}
 	return true;
-}
+}
\ No newline at end of file
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index f427195..b557684 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -1539,20 +1539,4 @@
 exit:
 	return TW_DEFAULT_RECOVERY_FOLDER;
 }
-
-bool TWFunc::Check_Xml_Format(const std::string filename) {
-	std::string buffer(' ', 4);
-	std::string abx_hdr("ABX\x00", 4);
-	std::ifstream File;
-	File.open(filename);
-	if (File.is_open()) {
-		File.get(&buffer[0], buffer.size());
-		File.close();
-		// Android Binary Xml start from these bytes
-		if(!buffer.compare(0, abx_hdr.size(), abx_hdr))
-			return false; // ABX format - requires conversion
-	}
-	return true; // good format, possible to parse
-}
-
 #endif // ndef BUILD_TWRPTAR_MAIN
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 4c25cf4..e5656f5 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -131,7 +131,6 @@
 	static void List_Mounts(); // List current mounts by the kernel
 	static void Clear_Bootloader_Message(); // Removes the bootloader message from misc for next boot
 	static string Check_For_TwrpFolder(); // Gets user defined path on storage where backups should be stored
-	static bool Check_Xml_Format(const std::string filename); // Return whether a xml is in plain xml or ABX format
 
 private:
 	static void Copy_Log(string Source, string Destination);