performance profile support

Many device trees support the recovery.perf.mode property to
set various core frequencies and online/offline mode. TWRP is
highly threaded, and support for multiple cores on many operations
dramatically recudes the time, e.g., backups, zip flashes, etc.

p2: removed user notifications

Change-Id: I957b8ca40b241c0af0471327eeb329cce1816017
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index b2d7b4e..7215374 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -651,9 +651,11 @@
 	pos = section_time / (float) total_time;
 	//DataManager::ShowProgress(pos, section_time);
 
+	TWFunc::SetPerformanceMode(true);
 	time(&start);
 
 	if (Part->Backup(Backup_Folder, &total_size, &current_size)) {
+		bool md5Success = false;
 		current_size += Part->Backup_Size;
 		pos = (float)((float)(current_size) / (float)(total_size));
 		DataManager::SetProgress(pos);
@@ -662,12 +664,16 @@
 
 			for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
 				if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point) {
-					if (!(*subpart)->Backup(Backup_Folder, &total_size, &current_size))
+					if (!(*subpart)->Backup(Backup_Folder, &total_size, &current_size)) {
+						TWFunc::SetPerformanceMode(false);
 						return false;
+					}
 					sync();
 					sync();
-					if (!Make_MD5(generate_md5, Backup_Folder, (*subpart)->Backup_FileName))
+					if (!Make_MD5(generate_md5, Backup_Folder, (*subpart)->Backup_FileName)) {
+						TWFunc::SetPerformanceMode(false);
 						return false;
+					}
 					if (Part->Backup_Method == 1) {
 						*file_bytes_remaining -= (*subpart)->Backup_Size;
 					} else {
@@ -689,8 +695,12 @@
 			*img_bytes_remaining -= Part->Backup_Size;
 			*img_time += backup_time;
 		}
-		return Make_MD5(generate_md5, Backup_Folder, Part->Backup_FileName);
+
+		md5Success = Make_MD5(generate_md5, Backup_Folder, Part->Backup_FileName);
+		TWFunc::SetPerformanceMode(false);
+		return md5Success;
 	} else {
+		TWFunc::SetPerformanceMode(false);
 		return false;
 	}
 }
@@ -862,21 +872,27 @@
 
 bool TWPartitionManager::Restore_Partition(TWPartition* Part, string Restore_Name, int partition_count, const unsigned long long *total_restore_size, unsigned long long *already_restored_size) {
 	time_t Start, Stop;
+	TWFunc::SetPerformanceMode(true);
 	time(&Start);
 	//DataManager::ShowProgress(1.0 / (float)partition_count, 150);
-	if (!Part->Restore(Restore_Name, total_restore_size, already_restored_size))
+	if (!Part->Restore(Restore_Name, total_restore_size, already_restored_size)) {
+		TWFunc::SetPerformanceMode(false);
 		return false;
+	}
 	if (Part->Has_SubPartition) {
 		std::vector<TWPartition*>::iterator subpart;
 
 		for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) {
 			if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == Part->Mount_Point) {
-				if (!(*subpart)->Restore(Restore_Name, total_restore_size, already_restored_size))
+				if (!(*subpart)->Restore(Restore_Name, total_restore_size, already_restored_size)) {
+					TWFunc::SetPerformanceMode(false);
 					return false;
+				}
 			}
 		}
 	}
 	time(&Stop);
+	TWFunc::SetPerformanceMode(false);
 	gui_print("[%s done (%d seconds)]\n\n", Part->Backup_Display_Name.c_str(), (int)difftime(Stop, Start));
 	return true;
 }