From 83a3b1260d7a371fe0d31e10361f38f311b99ece Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Mon, 1 Oct 2012 14:16:43 -0400 Subject: Update ORS and recovery commands --- openrecoveryscript.cpp | 247 ++++++++++++++++++++++++++----------------------- openrecoveryscript.hpp | 4 +- recovery.cpp | 31 ++++++- 3 files changed, 161 insertions(+), 121 deletions(-) diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp index 23641f7f3..88d54aca4 100644 --- a/openrecoveryscript.cpp +++ b/openrecoveryscript.cpp @@ -109,58 +109,8 @@ int OpenRecoveryScript::run_script_file(void) { ui_print("command is: '%s' and there is no value\n", command); } if (strcmp(command, "install") == 0) { - // Install zip - string ret_string; - - PartitionManager.Mount_All_Storage(); - if (value[0] != '/') { - // Relative path given - char full_path[SCRIPT_COMMAND_SIZE]; - - sprintf(full_path, "%s/%s", DataManager_GetCurrentStoragePath(), value); - LOGI("Full zip path: '%s'\n", full_path); - if (!TWFunc::Path_Exists(full_path)) { - ret_string = Locate_Zip_File(full_path, DataManager_GetCurrentStoragePath()); - if (!ret_string.empty()) { - strcpy(full_path, ret_string.c_str()); - } else if (DataManager_GetIntValue(TW_HAS_DUAL_STORAGE)) { - if (DataManager_GetIntValue(TW_USE_EXTERNAL_STORAGE)) { - LOGI("Zip file not found on external storage, trying internal...\n"); - DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 0); - } else { - LOGI("Zip file not found on internal storage, trying external...\n"); - DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 1); - } - sprintf(full_path, "%s/%s", DataManager_GetCurrentStoragePath(), value); - LOGI("Full zip path: '%s'\n", full_path); - ret_string = Locate_Zip_File(full_path, DataManager_GetCurrentStoragePath()); - if (!ret_string.empty()) - strcpy(full_path, ret_string.c_str()); - } - } - strcpy(value, full_path); - } else { - // Full path given - if (!TWFunc::Path_Exists(value)) { - ret_string = Locate_Zip_File(value, DataManager_GetCurrentStoragePath()); - if (!ret_string.empty()) - strcpy(value, ret_string.c_str()); - } - } - int wipe_cache = 0; - if (!TWFunc::Path_Exists(value)) { - // zip file doesn't exist - ui_print("Unable to locate zip file '%s'.\n", value); - ret_val = 1; - } else { - ui_print("Installing zip file '%s'\n", value); - ret_val = TWinstall_zip(value, &wipe_cache); - } - if (ret_val != 0) { - LOGE("Error installing zip file '%s'\n", value); - ret_val = 1; - } else if (wipe_cache) - PartitionManager.Wipe_By_Path("/cache"); + // Install Zip + ret_val = Install_Command(value); } else if (strcmp(command, "wipe") == 0) { // Wipe if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) { @@ -207,67 +157,7 @@ int OpenRecoveryScript::run_script_file(void) { strcpy(empt, "(Current Date)"); DataManager_SetStrValue(TW_BACKUP_NAME, empt); } - - DataManager_SetIntValue(TW_BACKUP_SYSTEM_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_DATA_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_CACHE_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_RECOVERY_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_SP1_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_SP2_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_SP3_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_BOOT_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_ANDSEC_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_SDEXT_VAR, 0); - DataManager_SetIntValue(TW_BACKUP_SDEXT_VAR, 0); - DataManager_SetIntValue(TW_USE_COMPRESSION_VAR, 0); - DataManager_SetIntValue(TW_SKIP_MD5_GENERATE_VAR, 0); - - ui_print("Setting backup options:\n"); - line_len = strlen(value1); - for (i=0; iShowText(true); break; case 'x': just_exit = true; break; + case 'n': perform_backup = true; LOGI("nandroid\n"); break; case '?': LOGE("Invalid command argument\n"); continue; @@ -899,8 +902,22 @@ main(int argc, char **argv) { int status = INSTALL_SUCCESS; + if (perform_backup) { + char empt[50]; + gui_console_only(); + strcpy(empt, "(Current Date)"); + DataManager_SetStrValue(TW_BACKUP_NAME, empt); + if (OpenRecoveryScript::Backup_Command("BSDCAE") != 0) + status = INSTALL_ERROR; + } + if (status == INSTALL_SUCCESS) { // Prevent other actions if backup failed if (update_package != NULL) { gui_console_only(); + if (OpenRecoveryScript::Install_Command(update_package) == 0) + status = INSTALL_SUCCESS; + else + status = INSTALL_ERROR; + /* status = install_package(update_package, &wipe_cache, TEMPORARY_INSTALL_FILE); if (status == INSTALL_SUCCESS && wipe_cache) { if (erase_volume("/cache")) { @@ -908,12 +925,15 @@ main(int argc, char **argv) { } } if (status != INSTALL_SUCCESS) ui->Print("Installation aborted.\n"); + */ } else if (wipe_data) { gui_console_only(); - if (PartitionManager.Factory_Reset()) status = INSTALL_ERROR; - //if (device->WipeData()) status = INSTALL_ERROR; - //if (erase_volume("/data")) status = INSTALL_ERROR; - //if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; + if (!PartitionManager.Factory_Reset()) status = INSTALL_ERROR; + /* + if (device->WipeData()) status = INSTALL_ERROR; + if (erase_volume("/data")) status = INSTALL_ERROR; + if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR; + */ if (status != INSTALL_SUCCESS) ui->Print("Data wipe failed.\n"); } else if (wipe_cache) { gui_console_only(); @@ -922,6 +942,7 @@ main(int argc, char **argv) { } else if (!just_exit) { status = INSTALL_ERROR; // No command specified } + } //if (status != INSTALL_SUCCESS) ui->SetBackground(RecoveryUI::ERROR); if (status != INSTALL_SUCCESS /*|| ui->IsTextVisible()*/) { @@ -930,7 +951,7 @@ main(int argc, char **argv) { if (DataManager_GetIntValue(TW_IS_ENCRYPTED) == 0 && OpenRecoveryScript::check_for_script_file()) { gui_console_only(); OpenRecoveryScript::run_script_file(); - if (1 || OpenRecoveryScript::run_script_file() != 0) { + if (OpenRecoveryScript::run_script_file() != 0) { // There was an error, boot the recovery gui_start(); } else { -- cgit v1.2.3