From 3aa66be4f2d5228cf35bad81e5a0a9a59a539678 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Tue, 22 Dec 2015 12:30:18 -0600 Subject: Append AOSP recovery commands inline Appending the AOSP recovery commands to the ORS command file as we process the commands will allow us to do things such as install multiple zip files, wipe cache, etc and do the actions in the order that those actions were originally requested. Change-Id: I375c1ccd3976123b818f1f492e971e615ec28c91 --- twrp.cpp | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'twrp.cpp') diff --git a/twrp.cpp b/twrp.cpp index b33a6ad1a..4f426640c 100644 --- a/twrp.cpp +++ b/twrp.cpp @@ -178,8 +178,8 @@ int main(int argc, char **argv) { PartitionManager.Mount_By_Path("/cache", true); - string Zip_File, Reboot_Value; - bool Cache_Wipe = false, Factory_Reset = false, Perform_Backup = false, Shutdown = false; + string Reboot_Value; + bool Shutdown = false; { TWPartition* misc = PartitionManager.Find_Partition_By_Path("/misc"); @@ -213,16 +213,25 @@ int main(int argc, char **argv) { while (*ptr == '=') ptr++; if (*ptr) { - Zip_File = ptr; + string ORSCommand = "install "; + ORSCommand.append(ptr); + + if (!OpenRecoveryScript::Insert_ORS_Command(ORSCommand)) + break; } else LOGERR("argument error specifying zip file\n"); } else if (*argptr == 'w') { - if (len == 9) - Factory_Reset = true; - else if (len == 10) - Cache_Wipe = true; + if (len == 9) { + if (!OpenRecoveryScript::Insert_ORS_Command("wipe data\n")) + break; + } else if (len == 10) { + if (!OpenRecoveryScript::Insert_ORS_Command("wipe cache\n")) + break; + } } else if (*argptr == 'n') { - Perform_Backup = true; + DataManager::SetValue(TW_BACKUP_NAME, gui_parse_text("{@auto_generate}")); + if (!OpenRecoveryScript::Insert_ORS_Command("backup BSDCAE\n")) + break; } else if (*argptr == 'p') { Shutdown = true; } else if (*argptr == 's') { @@ -262,28 +271,6 @@ int main(int argc, char **argv) { LOGINFO("Backup of TWRP ramdisk done.\n"); #endif - bool Keep_Going = true; - if (Perform_Backup) { - DataManager::SetValue(TW_BACKUP_NAME, "(Auto Generate)"); - if (!OpenRecoveryScript::Insert_ORS_Command("backup BSDCAE\n")) - Keep_Going = false; - } - if (Keep_Going && !Zip_File.empty()) { - string ORSCommand = "install " + Zip_File; - - if (!OpenRecoveryScript::Insert_ORS_Command(ORSCommand)) - Keep_Going = false; - } - if (Keep_Going) { - if (Factory_Reset) { - if (!OpenRecoveryScript::Insert_ORS_Command("wipe data\n")) - Keep_Going = false; - } else if (Cache_Wipe) { - if (!OpenRecoveryScript::Insert_ORS_Command("wipe cache\n")) - Keep_Going = false; - } - } - TWFunc::Update_Log_File(); // Offer to decrypt if the device is encrypted if (DataManager::GetIntValue(TW_IS_ENCRYPTED) != 0) { -- cgit v1.2.3