diff options
author | Dees_Troy <dees_troy@teamw.in> | 2012-10-01 20:16:43 +0200 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2012-10-01 20:16:43 +0200 |
commit | 83a3b1260d7a371fe0d31e10361f38f311b99ece (patch) | |
tree | 5e150c35f574162616a8981da480bcf8107fe9bf /recovery.cpp | |
parent | Fix output of version number (diff) | |
download | android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar.gz android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar.bz2 android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar.lz android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar.xz android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.tar.zst android_bootable_recovery-83a3b1260d7a371fe0d31e10361f38f311b99ece.zip |
Diffstat (limited to 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/recovery.cpp b/recovery.cpp index 1e1d9a952..ea085d15d 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -69,6 +69,7 @@ static const struct option OPTIONS[] = { { "wipe_cache", no_argument, NULL, 'c' }, { "show_text", no_argument, NULL, 't' }, { "just_exit", no_argument, NULL, 'x' }, + { "nandroid", no_argument, NULL, 'n' }, { NULL, 0, NULL, 0 }, }; @@ -829,6 +830,7 @@ main(int argc, char **argv) { const char *update_package = NULL; int wipe_data = 0, wipe_cache = 0; bool just_exit = false; + bool perform_backup = false; int arg; while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { @@ -840,6 +842,7 @@ main(int argc, char **argv) { case 'c': wipe_cache = 1; break; case 't': ui->ShowText(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 { |