Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 1 | /* OpenRecoveryScript class for TWRP |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | * You should have received a copy of the GNU General Public License |
| 13 | * along with this program; if not, write to the Free Software |
| 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 15 | * 02110-1301, USA. |
| 16 | * |
| 17 | * The code was written from scratch by Dees_Troy dees_troy at |
| 18 | * yahoo |
| 19 | * |
| 20 | * Copyright (c) 2012 |
| 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <string.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <sys/vfs.h> |
| 28 | #include <unistd.h> |
| 29 | #include <vector> |
| 30 | #include <dirent.h> |
| 31 | #include <time.h> |
| 32 | #include <errno.h> |
Dees_Troy | 01b6d0c | 2013-01-22 01:41:09 +0000 | [diff] [blame] | 33 | #include <iostream> |
| 34 | #include <fstream> |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 35 | |
| 36 | #include "twrp-functions.hpp" |
| 37 | #include "partitions.hpp" |
| 38 | #include "common.h" |
| 39 | #include "openrecoveryscript.hpp" |
| 40 | #include "variables.h" |
Dees_Troy | 4fc0024 | 2013-01-17 19:22:12 +0000 | [diff] [blame] | 41 | #include "adb_install.h" |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 42 | #include "data.hpp" |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 43 | extern "C" { |
Dees_Troy | 01b6d0c | 2013-01-22 01:41:09 +0000 | [diff] [blame] | 44 | #include "twinstall.h" |
| 45 | #include "gui/gui.h" |
| 46 | int TWinstall_zip(const char* path, int* wipe_cache); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 47 | } |
| 48 | |
Dees_Troy | 4fc0024 | 2013-01-17 19:22:12 +0000 | [diff] [blame] | 49 | extern RecoveryUI* ui; |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 50 | #define SCRIPT_COMMAND_SIZE 512 |
| 51 | |
| 52 | int OpenRecoveryScript::check_for_script_file(void) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 53 | if (!PartitionManager.Mount_By_Path(SCRIPT_FILE_CACHE, false)) { |
| 54 | LOGE("Unable to mount /cache for OpenRecoveryScript support.\n"); |
| 55 | return 0; |
| 56 | } |
| 57 | if (TWFunc::Path_Exists(SCRIPT_FILE_CACHE)) { |
| 58 | LOGI("Script file found: '%s'\n", SCRIPT_FILE_CACHE); |
| 59 | // Copy script file to /tmp |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 60 | TWFunc::copy_file(SCRIPT_FILE_CACHE, SCRIPT_FILE_TMP, 0755); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 61 | // Delete the file from /cache |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 62 | unlink(SCRIPT_FILE_CACHE); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 63 | return 1; |
| 64 | } |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | int OpenRecoveryScript::run_script_file(void) { |
| 69 | FILE *fp = fopen(SCRIPT_FILE_TMP, "r"); |
Dees_Troy | 4bc09ae | 2013-01-18 17:00:54 +0000 | [diff] [blame] | 70 | int ret_val = 0, cindex, line_len, i, remove_nl, install_cmd = 0, sideload = 0; |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 71 | char script_line[SCRIPT_COMMAND_SIZE], command[SCRIPT_COMMAND_SIZE], |
| 72 | value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE], |
| 73 | value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE]; |
| 74 | char *val_start, *tok; |
| 75 | |
| 76 | if (fp != NULL) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 77 | DataManager::SetValue(TW_SIMULATE_ACTIONS, 0); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 78 | while (fgets(script_line, SCRIPT_COMMAND_SIZE, fp) != NULL && ret_val == 0) { |
| 79 | cindex = 0; |
| 80 | line_len = strlen(script_line); |
| 81 | if (line_len < 2) |
| 82 | continue; // there's a blank line or line is too short to contain a command |
| 83 | //ui_print("script line: '%s'\n", script_line); |
| 84 | for (i=0; i<line_len; i++) { |
| 85 | if ((int)script_line[i] == 32) { |
| 86 | cindex = i; |
| 87 | i = line_len; |
| 88 | } |
| 89 | } |
| 90 | memset(command, 0, sizeof(command)); |
| 91 | memset(value, 0, sizeof(value)); |
| 92 | if ((int)script_line[line_len - 1] == 10) |
| 93 | remove_nl = 2; |
| 94 | else |
| 95 | remove_nl = 1; |
| 96 | if (cindex != 0) { |
| 97 | strncpy(command, script_line, cindex); |
| 98 | LOGI("command is: '%s' and ", command); |
| 99 | val_start = script_line; |
| 100 | val_start += cindex + 1; |
| 101 | strncpy(value, val_start, line_len - cindex - remove_nl); |
| 102 | LOGI("value is: '%s'\n", value); |
| 103 | } else { |
| 104 | strncpy(command, script_line, line_len - remove_nl + 1); |
| 105 | ui_print("command is: '%s' and there is no value\n", command); |
| 106 | } |
| 107 | if (strcmp(command, "install") == 0) { |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 108 | // Install Zip |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 109 | DataManager::SetValue("tw_action_text2", "Installing Zip"); |
Dees_Troy | dc8bc1b | 2013-01-17 01:39:28 +0000 | [diff] [blame] | 110 | PartitionManager.Mount_All_Storage(); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 111 | ret_val = Install_Command(value); |
Dees_Troy | 06b4fe9 | 2012-10-16 11:43:20 -0400 | [diff] [blame] | 112 | install_cmd = -1; |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 113 | } else if (strcmp(command, "wipe") == 0) { |
| 114 | // Wipe |
| 115 | if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) { |
| 116 | ui_print("-- Wiping Cache Partition...\n"); |
| 117 | PartitionManager.Wipe_By_Path("/cache"); |
| 118 | ui_print("-- Cache Partition Wipe Complete!\n"); |
| 119 | } else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) { |
| 120 | ui_print("-- Wiping Dalvik Cache...\n"); |
| 121 | PartitionManager.Wipe_Dalvik_Cache(); |
| 122 | ui_print("-- Dalvik Cache Wipe Complete!\n"); |
| 123 | } else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) { |
| 124 | ui_print("-- Wiping Data Partition...\n"); |
| 125 | PartitionManager.Factory_Reset(); |
| 126 | ui_print("-- Data Partition Wipe Complete!\n"); |
| 127 | } else { |
| 128 | LOGE("Error with wipe command value: '%s'\n", value); |
| 129 | ret_val = 1; |
| 130 | } |
| 131 | } else if (strcmp(command, "backup") == 0) { |
| 132 | // Backup |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 133 | DataManager::SetValue("tw_action_text2", "Backing Up"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 134 | tok = strtok(value, " "); |
| 135 | strcpy(value1, tok); |
| 136 | tok = strtok(NULL, " "); |
| 137 | if (tok != NULL) { |
| 138 | memset(value2, 0, sizeof(value2)); |
| 139 | strcpy(value2, tok); |
| 140 | line_len = strlen(tok); |
| 141 | if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13) { |
| 142 | if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13) |
| 143 | remove_nl = 2; |
| 144 | else |
| 145 | remove_nl = 1; |
| 146 | } else |
| 147 | remove_nl = 0; |
| 148 | strncpy(value2, tok, line_len - remove_nl); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 149 | DataManager::SetValue(TW_BACKUP_NAME, value2); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 150 | ui_print("Backup folder set to '%s'\n", value2); |
Dees_Troy | c9ff7a3 | 2012-09-27 10:09:41 -0400 | [diff] [blame] | 151 | if (PartitionManager.Check_Backup_Name(true) != 0) { |
| 152 | ret_val = 1; |
| 153 | continue; |
| 154 | } |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 155 | } else { |
| 156 | char empt[50]; |
| 157 | strcpy(empt, "(Current Date)"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 158 | DataManager::SetValue(TW_BACKUP_NAME, empt); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 159 | } |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 160 | ret_val = Backup_Command(value1); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 161 | } else if (strcmp(command, "restore") == 0) { |
| 162 | // Restore |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 163 | DataManager::SetValue("tw_action_text2", "Restoring"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 164 | PartitionManager.Mount_All_Storage(); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 165 | DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 0); |
Dees_Troy | dc8bc1b | 2013-01-17 01:39:28 +0000 | [diff] [blame] | 166 | char folder_path[512], partitions[512]; |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 167 | |
| 168 | string val = value, restore_folder, restore_partitions; |
| 169 | size_t pos = val.find_last_of(" "); |
| 170 | if (pos == string::npos) { |
Dees_Troy | dc8bc1b | 2013-01-17 01:39:28 +0000 | [diff] [blame] | 171 | restore_folder = value; |
| 172 | partitions[0] = '\0'; |
| 173 | } else { |
| 174 | restore_folder = val.substr(0, pos); |
| 175 | restore_partitions = val.substr(pos + 1, val.size() - pos - 1); |
| 176 | strcpy(partitions, restore_partitions.c_str()); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 177 | } |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 178 | strcpy(folder_path, restore_folder.c_str()); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 179 | LOGI("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions); |
| 180 | ui_print("Restoring '%s'\n", folder_path); |
| 181 | |
| 182 | if (folder_path[0] != '/') { |
| 183 | char backup_folder[512]; |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 184 | string folder_var; |
| 185 | DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var); |
| 186 | sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 187 | LOGI("Restoring relative path: '%s'\n", backup_folder); |
| 188 | if (!TWFunc::Path_Exists(backup_folder)) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 189 | if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) { |
| 190 | if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 191 | LOGI("Backup folder '%s' not found on external storage, trying internal...\n", folder_path); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 192 | DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 193 | } else { |
| 194 | LOGI("Backup folder '%s' not found on internal storage, trying external...\n", folder_path); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 195 | DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 196 | } |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 197 | DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var); |
| 198 | sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 199 | LOGI("2Restoring relative path: '%s'\n", backup_folder); |
| 200 | } |
| 201 | } |
| 202 | strcpy(folder_path, backup_folder); |
| 203 | } else { |
| 204 | if (folder_path[strlen(folder_path) - 1] == '/') |
| 205 | strcat(folder_path, "."); |
| 206 | else |
| 207 | strcat(folder_path, "/."); |
| 208 | } |
| 209 | if (!TWFunc::Path_Exists(folder_path)) { |
| 210 | ui_print("Unable to locate backup '%s'\n", folder_path); |
| 211 | ret_val = 1; |
| 212 | continue; |
| 213 | } |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 214 | DataManager::SetValue("tw_restore", folder_path); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 215 | |
| 216 | PartitionManager.Set_Restore_Files(folder_path); |
| 217 | if (strlen(partitions) != 0) { |
| 218 | int tw_restore_system = 0; |
| 219 | int tw_restore_data = 0; |
| 220 | int tw_restore_cache = 0; |
| 221 | int tw_restore_recovery = 0; |
| 222 | int tw_restore_boot = 0; |
| 223 | int tw_restore_andsec = 0; |
| 224 | int tw_restore_sdext = 0; |
| 225 | int tw_restore_sp1 = 0; |
| 226 | int tw_restore_sp2 = 0; |
| 227 | int tw_restore_sp3 = 0; |
| 228 | |
| 229 | memset(value2, 0, sizeof(value2)); |
| 230 | strcpy(value2, partitions); |
| 231 | ui_print("Setting restore options: '%s':\n", value2); |
| 232 | line_len = strlen(value2); |
| 233 | for (i=0; i<line_len; i++) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 234 | if ((value2[i] == 'S' || value2[i] == 's') && DataManager::GetIntValue(TW_RESTORE_SYSTEM_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 235 | tw_restore_system = 1; |
| 236 | ui_print("System\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 237 | } else if ((value2[i] == 'D' || value2[i] == 'd') && DataManager::GetIntValue(TW_RESTORE_DATA_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 238 | tw_restore_data = 1; |
| 239 | ui_print("Data\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 240 | } else if ((value2[i] == 'C' || value2[i] == 'c') && DataManager::GetIntValue(TW_RESTORE_CACHE_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 241 | tw_restore_cache = 1; |
| 242 | ui_print("Cache\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 243 | } else if ((value2[i] == 'R' || value2[i] == 'r') && DataManager::GetIntValue(TW_RESTORE_RECOVERY_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 244 | tw_restore_recovery = 1; |
| 245 | ui_print("Recovery\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 246 | } else if (value2[i] == '1' && DataManager::GetIntValue(TW_RESTORE_SP1_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 247 | tw_restore_sp1 = 1; |
| 248 | ui_print("%s\n", "Special1"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 249 | } else if (value2[i] == '2' && DataManager::GetIntValue(TW_RESTORE_SP2_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 250 | tw_restore_sp2 = 1; |
| 251 | ui_print("%s\n", "Special2"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 252 | } else if (value2[i] == '3' && DataManager::GetIntValue(TW_RESTORE_SP3_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 253 | tw_restore_sp3 = 1; |
| 254 | ui_print("%s\n", "Special3"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 255 | } else if ((value2[i] == 'B' || value2[i] == 'b') && DataManager::GetIntValue(TW_RESTORE_BOOT_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 256 | tw_restore_boot = 1; |
| 257 | ui_print("Boot\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 258 | } else if ((value2[i] == 'A' || value2[i] == 'a') && DataManager::GetIntValue(TW_RESTORE_ANDSEC_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 259 | tw_restore_andsec = 1; |
| 260 | ui_print("Android Secure\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 261 | } else if ((value2[i] == 'E' || value2[i] == 'e') && DataManager::GetIntValue(TW_RESTORE_SDEXT_VAR) > 0) { |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 262 | tw_restore_sdext = 1; |
| 263 | ui_print("SD-Ext\n"); |
| 264 | } else if (value2[i] == 'M' || value2[i] == 'm') { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 265 | DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 266 | ui_print("MD5 check skip is on\n"); |
| 267 | } |
| 268 | } |
| 269 | |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 270 | if (DataManager::GetIntValue(TW_RESTORE_SYSTEM_VAR) && !tw_restore_system) |
| 271 | DataManager::SetValue(TW_RESTORE_SYSTEM_VAR, 0); |
| 272 | if (DataManager::GetIntValue(TW_RESTORE_DATA_VAR) && !tw_restore_data) |
| 273 | DataManager::SetValue(TW_RESTORE_DATA_VAR, 0); |
| 274 | if (DataManager::GetIntValue(TW_RESTORE_CACHE_VAR) && !tw_restore_cache) |
| 275 | DataManager::SetValue(TW_RESTORE_CACHE_VAR, 0); |
| 276 | if (DataManager::GetIntValue(TW_RESTORE_RECOVERY_VAR) && !tw_restore_recovery) |
| 277 | DataManager::SetValue(TW_RESTORE_RECOVERY_VAR, 0); |
| 278 | if (DataManager::GetIntValue(TW_RESTORE_BOOT_VAR) && !tw_restore_boot) |
| 279 | DataManager::SetValue(TW_RESTORE_BOOT_VAR, 0); |
| 280 | if (DataManager::GetIntValue(TW_RESTORE_ANDSEC_VAR) && !tw_restore_andsec) |
| 281 | DataManager::SetValue(TW_RESTORE_ANDSEC_VAR, 0); |
| 282 | if (DataManager::GetIntValue(TW_RESTORE_SDEXT_VAR) && !tw_restore_sdext) |
| 283 | DataManager::SetValue(TW_RESTORE_SDEXT_VAR, 0); |
| 284 | if (DataManager::GetIntValue(TW_RESTORE_SP1_VAR) && !tw_restore_sp1) |
| 285 | DataManager::SetValue(TW_RESTORE_SP1_VAR, 0); |
| 286 | if (DataManager::GetIntValue(TW_RESTORE_SP2_VAR) && !tw_restore_sp2) |
| 287 | DataManager::SetValue(TW_RESTORE_SP2_VAR, 0); |
| 288 | if (DataManager::GetIntValue(TW_RESTORE_SP3_VAR) && !tw_restore_sp3) |
| 289 | DataManager::SetValue(TW_RESTORE_SP3_VAR, 0); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 290 | } |
| 291 | PartitionManager.Run_Restore(folder_path); |
| 292 | ui_print("Restore complete!\n"); |
| 293 | } else if (strcmp(command, "mount") == 0) { |
| 294 | // Mount |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 295 | DataManager::SetValue("tw_action_text2", "Mounting"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 296 | if (value[0] != '/') { |
| 297 | strcpy(mount, "/"); |
| 298 | strcat(mount, value); |
| 299 | } else |
| 300 | strcpy(mount, value); |
| 301 | if (PartitionManager.Mount_By_Path(mount, true)) |
| 302 | ui_print("Mounted '%s'\n", mount); |
| 303 | } else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) { |
| 304 | // Unmount |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 305 | DataManager::SetValue("tw_action_text2", "Unmounting"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 306 | if (value[0] != '/') { |
| 307 | strcpy(mount, "/"); |
| 308 | strcat(mount, value); |
| 309 | } else |
| 310 | strcpy(mount, value); |
| 311 | if (PartitionManager.UnMount_By_Path(mount, true)) |
| 312 | ui_print("Unmounted '%s'\n", mount); |
| 313 | } else if (strcmp(command, "set") == 0) { |
| 314 | // Set value |
| 315 | tok = strtok(value, " "); |
| 316 | strcpy(value1, tok); |
| 317 | tok = strtok(NULL, " "); |
| 318 | strcpy(value2, tok); |
| 319 | ui_print("Setting '%s' to '%s'\n", value1, value2); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 320 | DataManager::SetValue(value1, value2); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 321 | } else if (strcmp(command, "mkdir") == 0) { |
| 322 | // Make directory (recursive) |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 323 | DataManager::SetValue("tw_action_text2", "Making Directory"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 324 | ui_print("Making directory (recursive): '%s'\n", value); |
| 325 | if (TWFunc::Recursive_Mkdir(value)) { |
| 326 | LOGE("Unable to create folder: '%s'\n", value); |
| 327 | ret_val = 1; |
| 328 | } |
| 329 | } else if (strcmp(command, "reboot") == 0) { |
| 330 | // Reboot |
| 331 | } else if (strcmp(command, "cmd") == 0) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 332 | DataManager::SetValue("tw_action_text2", "Running Command"); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 333 | if (cindex != 0) { |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 334 | string status; |
| 335 | TWFunc::Exec_Cmd(value, status); |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 336 | } else { |
| 337 | LOGE("No value given for cmd\n"); |
| 338 | } |
| 339 | } else if (strcmp(command, "print") == 0) { |
| 340 | ui_print("%s\n", value); |
Dees_Troy | 4fc0024 | 2013-01-17 19:22:12 +0000 | [diff] [blame] | 341 | } else if (strcmp(command, "sideload") == 0) { |
Dees_Troy | 4bc09ae | 2013-01-18 17:00:54 +0000 | [diff] [blame] | 342 | // ADB Sideload |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 343 | DataManager::SetValue("tw_action_text2", "ADB Sideload"); |
| 344 | install_cmd = -1; |
| 345 | |
| 346 | int wipe_cache = 0; |
| 347 | string result, Sideload_File; |
| 348 | |
| 349 | if (!PartitionManager.Mount_Current_Storage(true)) { |
| 350 | ret_val = 1; // failure |
| 351 | } else { |
| 352 | Sideload_File = DataManager::GetCurrentStoragePath() + "/sideload.zip"; |
| 353 | if (TWFunc::Path_Exists(Sideload_File)) { |
| 354 | unlink(Sideload_File.c_str()); |
| 355 | } |
| 356 | ui_print("Starting ADB sideload feature...\n"); |
| 357 | DataManager::SetValue("tw_has_cancel", 1); |
| 358 | DataManager::SetValue("tw_cancel_action", "adbsideloadcancel"); |
| 359 | ret_val = apply_from_adb(ui, &wipe_cache, Sideload_File.c_str()); |
| 360 | DataManager::SetValue("tw_has_cancel", 0); |
| 361 | if (ret_val != 0) |
| 362 | ret_val = 1; // failure |
| 363 | else if (wipe_cache) |
| 364 | PartitionManager.Wipe_By_Path("/cache"); |
| 365 | sideload = 1; // Causes device to go to the home screen afterwards |
| 366 | ui_print("Sideload finished.\n"); |
Dees_Troy | 4fc0024 | 2013-01-17 19:22:12 +0000 | [diff] [blame] | 367 | } |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 368 | } else { |
| 369 | LOGE("Unrecognized script command: '%s'\n", command); |
| 370 | ret_val = 1; |
| 371 | } |
| 372 | } |
| 373 | fclose(fp); |
| 374 | ui_print("Done processing script file\n"); |
| 375 | } else { |
| 376 | LOGE("Error opening script file '%s'\n", SCRIPT_FILE_TMP); |
| 377 | return 1; |
| 378 | } |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 379 | if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) { |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 380 | string status; |
Dees_Troy | 06b4fe9 | 2012-10-16 11:43:20 -0400 | [diff] [blame] | 381 | ui_print("Injecting TWRP into boot image...\n"); |
| 382 | TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot"); |
| 383 | if (Boot == NULL || Boot->Current_File_System != "emmc") |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 384 | TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash", status); |
Dees_Troy | 06b4fe9 | 2012-10-16 11:43:20 -0400 | [diff] [blame] | 385 | else { |
| 386 | string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 387 | TWFunc::Exec_Cmd(injectcmd.c_str(), status); |
Dees_Troy | 06b4fe9 | 2012-10-16 11:43:20 -0400 | [diff] [blame] | 388 | } |
| 389 | ui_print("TWRP injection complete.\n"); |
| 390 | } |
Dees_Troy | 4bc09ae | 2013-01-18 17:00:54 +0000 | [diff] [blame] | 391 | if (sideload) |
| 392 | ret_val = 1; // Forces booting to the home page after sideload |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 393 | return ret_val; |
| 394 | } |
| 395 | |
Dees_Troy | 01b6d0c | 2013-01-22 01:41:09 +0000 | [diff] [blame] | 396 | int OpenRecoveryScript::Insert_ORS_Command(string Command) { |
| 397 | ofstream ORSfile(SCRIPT_FILE_TMP); |
| 398 | if (ORSfile.is_open()) { |
| 399 | //if (Command.substr(Command.size() - 1, 1) != "\n") |
| 400 | // Command += "\n"; |
| 401 | LOGI("Inserting '%s'\n", Command.c_str()); |
| 402 | ORSfile << Command.c_str(); |
| 403 | ORSfile.close(); |
| 404 | return 1; |
| 405 | } |
| 406 | LOGE("Unable to append '%s' to '%s'\n", Command.c_str(), SCRIPT_FILE_TMP); |
| 407 | return 0; |
| 408 | } |
| 409 | |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 410 | int OpenRecoveryScript::Install_Command(string Zip) { |
| 411 | // Install zip |
| 412 | string ret_string; |
| 413 | int ret_val = 0, wipe_cache = 0; |
| 414 | |
| 415 | PartitionManager.Mount_All_Storage(); |
| 416 | if (Zip.substr(0, 1) != "/") { |
| 417 | // Relative path given |
| 418 | string Full_Path; |
| 419 | |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 420 | Full_Path = DataManager::GetCurrentStoragePath(); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 421 | Full_Path += "/" + Zip; |
| 422 | LOGI("Full zip path: '%s'\n", Full_Path.c_str()); |
| 423 | if (!TWFunc::Path_Exists(Full_Path)) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 424 | ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath()); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 425 | if (!ret_string.empty()) { |
| 426 | Full_Path = ret_string; |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 427 | } else if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) { |
| 428 | if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) { |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 429 | LOGI("Zip file not found on external storage, trying internal...\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 430 | DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 431 | } else { |
| 432 | LOGI("Zip file not found on internal storage, trying external...\n"); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 433 | DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 434 | } |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 435 | Full_Path = DataManager::GetCurrentStoragePath(); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 436 | Full_Path += "/" + Zip; |
| 437 | LOGI("Full zip path: '%s'\n", Full_Path.c_str()); |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 438 | ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath()); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 439 | if (!ret_string.empty()) |
| 440 | Full_Path = ret_string; |
| 441 | } |
| 442 | } |
| 443 | Zip = Full_Path; |
| 444 | } else { |
| 445 | // Full path given |
| 446 | if (!TWFunc::Path_Exists(Zip)) { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 447 | ret_string = Locate_Zip_File(Zip, DataManager::GetCurrentStoragePath()); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 448 | if (!ret_string.empty()) |
| 449 | Zip = ret_string; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | if (!TWFunc::Path_Exists(Zip)) { |
| 454 | // zip file doesn't exist |
| 455 | ui_print("Unable to locate zip file '%s'.\n", Zip.c_str()); |
| 456 | ret_val = 1; |
| 457 | } else { |
| 458 | ui_print("Installing zip file '%s'\n", Zip.c_str()); |
| 459 | ret_val = TWinstall_zip(Zip.c_str(), &wipe_cache); |
| 460 | } |
| 461 | if (ret_val != 0) { |
| 462 | LOGE("Error installing zip file '%s'\n", Zip.c_str()); |
| 463 | ret_val = 1; |
| 464 | } else if (wipe_cache) |
| 465 | PartitionManager.Wipe_By_Path("/cache"); |
| 466 | |
| 467 | return ret_val; |
| 468 | } |
| 469 | |
Dees_Troy | 812660f | 2012-09-20 09:55:17 -0400 | [diff] [blame] | 470 | string OpenRecoveryScript::Locate_Zip_File(string Zip, string Storage_Root) { |
| 471 | string Path = TWFunc::Get_Path(Zip); |
| 472 | string File = TWFunc::Get_Filename(Zip); |
| 473 | string pathCpy = Path; |
| 474 | string wholePath; |
| 475 | size_t pos = Path.find("/", 1); |
| 476 | |
| 477 | while (pos != string::npos) |
| 478 | { |
| 479 | pathCpy = Path.substr(pos, Path.size() - pos); |
| 480 | wholePath = pathCpy + "/" + File; |
| 481 | if (TWFunc::Path_Exists(wholePath)) |
| 482 | return wholePath; |
| 483 | wholePath = Storage_Root + "/" + wholePath; |
| 484 | if (TWFunc::Path_Exists(wholePath)) |
| 485 | return wholePath; |
| 486 | |
| 487 | pos = Path.find("/", pos + 1); |
| 488 | } |
| 489 | return ""; |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | int OpenRecoveryScript::Backup_Command(string Options) { |
| 493 | char value1[SCRIPT_COMMAND_SIZE]; |
| 494 | int line_len, i; |
| 495 | |
| 496 | strcpy(value1, Options.c_str()); |
| 497 | |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 498 | DataManager::SetValue(TW_BACKUP_SYSTEM_VAR, 0); |
| 499 | DataManager::SetValue(TW_BACKUP_DATA_VAR, 0); |
| 500 | DataManager::SetValue(TW_BACKUP_CACHE_VAR, 0); |
| 501 | DataManager::SetValue(TW_BACKUP_RECOVERY_VAR, 0); |
| 502 | DataManager::SetValue(TW_BACKUP_SP1_VAR, 0); |
| 503 | DataManager::SetValue(TW_BACKUP_SP2_VAR, 0); |
| 504 | DataManager::SetValue(TW_BACKUP_SP3_VAR, 0); |
| 505 | DataManager::SetValue(TW_BACKUP_BOOT_VAR, 0); |
| 506 | DataManager::SetValue(TW_BACKUP_ANDSEC_VAR, 0); |
| 507 | DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 0); |
| 508 | DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 0); |
| 509 | DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0); |
| 510 | DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 511 | |
| 512 | ui_print("Setting backup options:\n"); |
| 513 | line_len = Options.size(); |
| 514 | for (i=0; i<line_len; i++) { |
| 515 | if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 516 | DataManager::SetValue(TW_BACKUP_SYSTEM_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 517 | ui_print("System\n"); |
| 518 | } else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 519 | DataManager::SetValue(TW_BACKUP_DATA_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 520 | ui_print("Data\n"); |
| 521 | } else if (Options.substr(i, 1) == "C" || Options.substr(i, 1) == "c") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 522 | DataManager::SetValue(TW_BACKUP_CACHE_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 523 | ui_print("Cache\n"); |
| 524 | } else if (Options.substr(i, 1) == "R" || Options.substr(i, 1) == "r") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 525 | DataManager::SetValue(TW_BACKUP_RECOVERY_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 526 | ui_print("Recovery\n"); |
| 527 | } else if (Options.substr(i, 1) == "1") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 528 | DataManager::SetValue(TW_BACKUP_SP1_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 529 | ui_print("%s\n", "Special1"); |
| 530 | } else if (Options.substr(i, 1) == "2") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 531 | DataManager::SetValue(TW_BACKUP_SP2_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 532 | ui_print("%s\n", "Special2"); |
| 533 | } else if (Options.substr(i, 1) == "3") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 534 | DataManager::SetValue(TW_BACKUP_SP3_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 535 | ui_print("%s\n", "Special3"); |
| 536 | } else if (Options.substr(i, 1) == "B" || Options.substr(i, 1) == "b") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 537 | DataManager::SetValue(TW_BACKUP_BOOT_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 538 | ui_print("Boot\n"); |
| 539 | } else if (Options.substr(i, 1) == "A" || Options.substr(i, 1) == "a") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 540 | DataManager::SetValue(TW_BACKUP_ANDSEC_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 541 | ui_print("Android Secure\n"); |
| 542 | } else if (Options.substr(i, 1) == "E" || Options.substr(i, 1) == "e") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 543 | DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 544 | ui_print("SD-Ext\n"); |
| 545 | } else if (Options.substr(i, 1) == "O" || Options.substr(i, 1) == "o") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 546 | DataManager::SetValue(TW_USE_COMPRESSION_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 547 | ui_print("Compression is on\n"); |
| 548 | } else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") { |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 549 | DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 1); |
Dees_Troy | 83a3b12 | 2012-10-01 14:16:43 -0400 | [diff] [blame] | 550 | ui_print("MD5 Generation is off\n"); |
| 551 | } |
| 552 | } |
| 553 | if (!PartitionManager.Run_Backup()) { |
| 554 | LOGE("Backup failed!\n"); |
| 555 | return 1; |
| 556 | } |
| 557 | ui_print("Backup complete!\n"); |
| 558 | return 0; |
| 559 | } |
Dees_Troy | 6ed34b7 | 2013-01-25 15:01:29 +0000 | [diff] [blame^] | 560 | |
| 561 | void OpenRecoveryScript::Run_OpenRecoveryScript(void) { |
| 562 | DataManager::SetValue("tw_back", "main"); |
| 563 | DataManager::SetValue("tw_action", "openrecoveryscript"); |
| 564 | DataManager::SetValue("tw_has_action2", "0"); |
| 565 | DataManager::SetValue("tw_action2", ""); |
| 566 | DataManager::SetValue("tw_action2_param", ""); |
| 567 | DataManager::SetValue("tw_action_text1", "Running OpenRecoveryScript"); |
| 568 | DataManager::SetValue("tw_action_text2", ""); |
| 569 | DataManager::SetValue("tw_complete_text1", "OpenRecoveryScript Complete"); |
| 570 | DataManager::SetValue("tw_has_cancel", 0); |
| 571 | DataManager::SetValue("tw_show_reboot", 0); |
| 572 | if (gui_startPage("action_page") != 0) { |
| 573 | LOGE("Failed to load OpenRecoveryScript GUI page.\n"); |
| 574 | } |
| 575 | } |