diff options
Diffstat (limited to '')
-rw-r--r-- | twrp.cpp | 47 |
1 files changed, 17 insertions, 30 deletions
@@ -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) { |