multiuser: Parse users only when Decrypt_DE runs successfully

Change-Id: I62b3ae3876843387a33ecf25501f7ee50f4c7f99
diff --git a/partition.cpp b/partition.cpp
index cb969a4..7ae43ba 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -741,18 +741,6 @@
 	int retry_count = 3;
 	while (!Decrypt_DE() && --retry_count)
 		usleep(2000);
-	PartitionManager.Parse_Users();  // after load_all_de_keys() to parse_users
-	std::vector<users_struct>::iterator iter;
-	std::vector<users_struct>* userList = PartitionManager.Get_Users_List();
-	for (iter = userList->begin(); iter != userList->end(); iter++) {
-		if (atoi((*iter).userId.c_str()) != 0) {
-			ExcludeAll(Mount_Point + "/system_de/" + (*iter).userId + "/spblob");
-			ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/gatekeeper.password.key");
-			ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/gatekeeper.pattern.key");
-			ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/locksettings.db");
-			ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/locksettings.db-wal");
-		}
-	}
 	if (retry_count > 0) {
 		property_set("ro.crypto.state", "encrypted");
 		Is_Encrypted = true;
@@ -764,6 +752,18 @@
 			LOGERR("This TWRP does not have synthetic password decrypt support\n");
 			pwd_type = 0;  // default password
 		}
+		PartitionManager.Parse_Users();  // after load_all_de_keys() to parse_users
+		std::vector<users_struct>::iterator iter;
+		std::vector<users_struct>* userList = PartitionManager.Get_Users_List();
+		for (iter = userList->begin(); iter != userList->end(); iter++) {
+			if (atoi((*iter).userId.c_str()) != 0) {
+				ExcludeAll(Mount_Point + "/system_de/" + (*iter).userId + "/spblob");
+				ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/gatekeeper.password.key");
+				ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/gatekeeper.pattern.key");
+				ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/locksettings.db");
+				ExcludeAll(Mount_Point + "/system/users/" + (*iter).userId + "/locksettings.db-wal");
+			}
+		}
 		DataManager::SetValue(TW_CRYPTO_PWTYPE, pwd_type);
 		DataManager::SetValue("tw_crypto_pwtype_0", pwd_type);
 		DataManager::SetValue(TW_CRYPTO_PASSWORD, "");
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index bcf891c..d5dc9fe 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1766,11 +1766,13 @@
 	std::vector<users_struct>::iterator iter;
 	for (iter = Users_List.begin(); iter != Users_List.end(); iter++) {
 		if (!(*iter).isDecrypted) {
+			LOGINFO("User %s is not decrypted.\n", (*iter).userId.c_str());
 			all_is_decrypted = 0;
 			break;
 		}
 	}
 	if (all_is_decrypted == 1) {
+		LOGINFO("All found users are decrypted.\n");
 		DataManager::SetValue("tw_all_users_decrypted", "1");
 		property_set("twrp.all.users.decrypted", "true");
 	} else