From a13d74fc95324c4318fcc95956b07fe593669412 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Sun, 24 Mar 2013 08:54:55 -0500 Subject: Add partition list GUI element Add partition list GUI element and update backup, restore, mount, storage selection, and wipe sections of GUI and partition manager code to reflect the new GUI element. Update ORS engine to handle new backup and restore setup. Fix a bug with decrypt. Add 1080x1920 layout. Change-Id: Iaa2f44cb707167e66f935452f076ba00e68a2aa4 --- openrecoveryscript.cpp | 116 +++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 77 deletions(-) (limited to 'openrecoveryscript.cpp') diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp index e319a9c61..5a23c1d4a 100644 --- a/openrecoveryscript.cpp +++ b/openrecoveryscript.cpp @@ -215,52 +215,41 @@ int OpenRecoveryScript::run_script_file(void) { DataManager::SetValue("tw_restore", folder_path); PartitionManager.Set_Restore_Files(folder_path); + string Partition_List; + DataManager::GetValue("tw_restore_list", Partition_List); if (strlen(partitions) != 0) { - int tw_restore_system = 0; - int tw_restore_data = 0; - int tw_restore_cache = 0; - int tw_restore_recovery = 0; - int tw_restore_boot = 0; - int tw_restore_andsec = 0; - int tw_restore_sdext = 0; - int tw_restore_sp1 = 0; - int tw_restore_sp2 = 0; - int tw_restore_sp3 = 0; + string Restore_List; memset(value2, 0, sizeof(value2)); strcpy(value2, partitions); ui_print("Setting restore options: '%s':\n", value2); line_len = strlen(value2); for (i=0; i 0) { - tw_restore_system = 1; + if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find("/system;") != string::npos) { + Restore_List += "/system;"; ui_print("System\n"); - } else if ((value2[i] == 'D' || value2[i] == 'd') && DataManager::GetIntValue(TW_RESTORE_DATA_VAR) > 0) { - tw_restore_data = 1; + } else if ((value2[i] == 'D' || value2[i] == 'd') && Partition_List.find("/data;") != string::npos) { + Restore_List += "/data;"; ui_print("Data\n"); - } else if ((value2[i] == 'C' || value2[i] == 'c') && DataManager::GetIntValue(TW_RESTORE_CACHE_VAR) > 0) { - tw_restore_cache = 1; + } else if ((value2[i] == 'C' || value2[i] == 'c') && Partition_List.find("/cache;") != string::npos) { + Restore_List += "/cache;"; ui_print("Cache\n"); - } else if ((value2[i] == 'R' || value2[i] == 'r') && DataManager::GetIntValue(TW_RESTORE_RECOVERY_VAR) > 0) { - tw_restore_recovery = 1; - ui_print("Recovery\n"); + } else if ((value2[i] == 'R' || value2[i] == 'r') && Partition_List.find("/recovery;") != string::npos) { + ui_print("Recovery -- Not allowed to restore recovery\n"); } else if (value2[i] == '1' && DataManager::GetIntValue(TW_RESTORE_SP1_VAR) > 0) { - tw_restore_sp1 = 1; - ui_print("%s\n", "Special1"); + ui_print("%s\n", "Special1 -- No Longer Supported..."); } else if (value2[i] == '2' && DataManager::GetIntValue(TW_RESTORE_SP2_VAR) > 0) { - tw_restore_sp2 = 1; - ui_print("%s\n", "Special2"); + ui_print("%s\n", "Special2 -- No Longer Supported..."); } else if (value2[i] == '3' && DataManager::GetIntValue(TW_RESTORE_SP3_VAR) > 0) { - tw_restore_sp3 = 1; - ui_print("%s\n", "Special3"); - } else if ((value2[i] == 'B' || value2[i] == 'b') && DataManager::GetIntValue(TW_RESTORE_BOOT_VAR) > 0) { - tw_restore_boot = 1; + ui_print("%s\n", "Special3 -- No Longer Supported..."); + } else if ((value2[i] == 'B' || value2[i] == 'b') && Partition_List.find("/boot;") != string::npos) { + Restore_List += "/boot;"; ui_print("Boot\n"); - } else if ((value2[i] == 'A' || value2[i] == 'a') && DataManager::GetIntValue(TW_RESTORE_ANDSEC_VAR) > 0) { - tw_restore_andsec = 1; + } else if ((value2[i] == 'A' || value2[i] == 'a') && Partition_List.find("/and-sec;") != string::npos) { + Restore_List += "/and-sec;"; ui_print("Android Secure\n"); - } else if ((value2[i] == 'E' || value2[i] == 'e') && DataManager::GetIntValue(TW_RESTORE_SDEXT_VAR) > 0) { - tw_restore_sdext = 1; + } else if ((value2[i] == 'E' || value2[i] == 'e') && Partition_List.find("/sd-ext;") != string::npos) { + Restore_List += "/sd-ext;"; ui_print("SD-Ext\n"); } else if (value2[i] == 'M' || value2[i] == 'm') { DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1); @@ -268,29 +257,14 @@ int OpenRecoveryScript::run_script_file(void) { } } - if (DataManager::GetIntValue(TW_RESTORE_SYSTEM_VAR) && !tw_restore_system) - DataManager::SetValue(TW_RESTORE_SYSTEM_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_DATA_VAR) && !tw_restore_data) - DataManager::SetValue(TW_RESTORE_DATA_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_CACHE_VAR) && !tw_restore_cache) - DataManager::SetValue(TW_RESTORE_CACHE_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_RECOVERY_VAR) && !tw_restore_recovery) - DataManager::SetValue(TW_RESTORE_RECOVERY_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_BOOT_VAR) && !tw_restore_boot) - DataManager::SetValue(TW_RESTORE_BOOT_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_ANDSEC_VAR) && !tw_restore_andsec) - DataManager::SetValue(TW_RESTORE_ANDSEC_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_SDEXT_VAR) && !tw_restore_sdext) - DataManager::SetValue(TW_RESTORE_SDEXT_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_SP1_VAR) && !tw_restore_sp1) - DataManager::SetValue(TW_RESTORE_SP1_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_SP2_VAR) && !tw_restore_sp2) - DataManager::SetValue(TW_RESTORE_SP2_VAR, 0); - if (DataManager::GetIntValue(TW_RESTORE_SP3_VAR) && !tw_restore_sp3) - DataManager::SetValue(TW_RESTORE_SP3_VAR, 0); + DataManager::SetValue("tw_restore_selected", Restore_List); + } else { + DataManager::SetValue("tw_restore_selected", Partition_List); } - PartitionManager.Run_Restore(folder_path); - ui_print("Restore complete!\n"); + if (!PartitionManager.Run_Restore(folder_path)) + ret_val = 1; + else + ui_print("Restore complete!\n"); } else if (strcmp(command, "mount") == 0) { // Mount DataManager::SetValue("tw_action_text2", "Mounting"); @@ -493,20 +467,10 @@ string OpenRecoveryScript::Locate_Zip_File(string Zip, string Storage_Root) { int OpenRecoveryScript::Backup_Command(string Options) { char value1[SCRIPT_COMMAND_SIZE]; int line_len, i; + string Backup_List; strcpy(value1, Options.c_str()); - DataManager::SetValue(TW_BACKUP_SYSTEM_VAR, 0); - DataManager::SetValue(TW_BACKUP_DATA_VAR, 0); - DataManager::SetValue(TW_BACKUP_CACHE_VAR, 0); - DataManager::SetValue(TW_BACKUP_RECOVERY_VAR, 0); - DataManager::SetValue(TW_BACKUP_SP1_VAR, 0); - DataManager::SetValue(TW_BACKUP_SP2_VAR, 0); - DataManager::SetValue(TW_BACKUP_SP3_VAR, 0); - DataManager::SetValue(TW_BACKUP_BOOT_VAR, 0); - DataManager::SetValue(TW_BACKUP_ANDSEC_VAR, 0); - DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 0); - DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 0); DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0); DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0); @@ -514,34 +478,31 @@ int OpenRecoveryScript::Backup_Command(string Options) { line_len = Options.size(); for (i=0; i