blob: eee64ff89f43e0c688cb5f650b6475e45a71a150 [file] [log] [blame]
Dees Troy3be70a82013-10-22 14:25:12 +00001/*
2 Copyright 2012 bigbiff/Dees_Troy TeamWin
3 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
Dees_Troy812660f2012-09-20 09:55:17 -040018
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <sys/stat.h>
23#include <sys/vfs.h>
24#include <unistd.h>
25#include <vector>
26#include <dirent.h>
27#include <time.h>
28#include <errno.h>
Dees_Troy01b6d0c2013-01-22 01:41:09 +000029#include <iostream>
30#include <fstream>
Ethan Yonkerd83587d2015-01-03 16:54:18 -060031#include <sys/types.h>
32#include <sys/wait.h>
Dees_Troy812660f2012-09-20 09:55:17 -040033
34#include "twrp-functions.hpp"
35#include "partitions.hpp"
Dees_Troy2673cec2013-04-02 20:22:16 +000036#include "twcommon.h"
Dees_Troy812660f2012-09-20 09:55:17 -040037#include "openrecoveryscript.hpp"
38#include "variables.h"
Dees_Troy4fc00242013-01-17 19:22:12 +000039#include "adb_install.h"
Dees_Troy6ed34b72013-01-25 15:01:29 +000040#include "data.hpp"
Ethan Yonkerd83587d2015-01-03 16:54:18 -060041#include "adb_install.h"
42#include "fuse_sideload.h"
Ethan Yonker74db1572015-10-28 12:44:49 -050043#include "gui/gui.hpp"
Dees_Troy812660f2012-09-20 09:55:17 -040044extern "C" {
Dees_Troy01b6d0c2013-01-22 01:41:09 +000045 #include "twinstall.h"
46 #include "gui/gui.h"
Ethan Yonkerd83587d2015-01-03 16:54:18 -060047 #include "cutils/properties.h"
Dees_Troy01b6d0c2013-01-22 01:41:09 +000048 int TWinstall_zip(const char* path, int* wipe_cache);
Dees_Troy812660f2012-09-20 09:55:17 -040049}
50
that10ae24f2015-12-26 20:53:51 +010051OpenRecoveryScript::VoidFunction OpenRecoveryScript::call_after_cli_command;
52
Dees_Troy812660f2012-09-20 09:55:17 -040053#define SCRIPT_COMMAND_SIZE 512
54
55int OpenRecoveryScript::check_for_script_file(void) {
Dees_Troy812660f2012-09-20 09:55:17 -040056 if (!PartitionManager.Mount_By_Path(SCRIPT_FILE_CACHE, false)) {
Ethan Yonker74db1572015-10-28 12:44:49 -050057 LOGINFO("Unable to mount /cache for OpenRecoveryScript support.\n");
58 gui_msg(Msg(msg::kError, "unable_to_mount=Unable to mount {1}")(SCRIPT_FILE_CACHE));
Dees_Troy812660f2012-09-20 09:55:17 -040059 return 0;
60 }
61 if (TWFunc::Path_Exists(SCRIPT_FILE_CACHE)) {
Dees_Troy2673cec2013-04-02 20:22:16 +000062 LOGINFO("Script file found: '%s'\n", SCRIPT_FILE_CACHE);
Dees_Troy812660f2012-09-20 09:55:17 -040063 // Copy script file to /tmp
bigbiff bigbiff9c754052013-01-09 09:09:08 -050064 TWFunc::copy_file(SCRIPT_FILE_CACHE, SCRIPT_FILE_TMP, 0755);
Dees_Troy812660f2012-09-20 09:55:17 -040065 // Delete the file from /cache
bigbiff bigbiff9c754052013-01-09 09:09:08 -050066 unlink(SCRIPT_FILE_CACHE);
Dees_Troy812660f2012-09-20 09:55:17 -040067 return 1;
68 }
69 return 0;
70}
71
Ethan Yonker03a42f62014-08-08 11:03:51 -050072int OpenRecoveryScript::copy_script_file(string filename) {
73 if (TWFunc::Path_Exists(filename)) {
74 LOGINFO("Script file found: '%s'\n", filename.c_str());
75 if (filename == SCRIPT_FILE_TMP)
76 return 1; // file is already in the right place
77 // Copy script file to /tmp
78 TWFunc::copy_file(filename, SCRIPT_FILE_TMP, 0755);
79 // Delete the old file
80 unlink(filename.c_str());
81 return 1;
82 }
83 return 0;
84}
85
Dees_Troy812660f2012-09-20 09:55:17 -040086int OpenRecoveryScript::run_script_file(void) {
87 FILE *fp = fopen(SCRIPT_FILE_TMP, "r");
Dees_Troy4bc09ae2013-01-18 17:00:54 +000088 int ret_val = 0, cindex, line_len, i, remove_nl, install_cmd = 0, sideload = 0;
Dees_Troy812660f2012-09-20 09:55:17 -040089 char script_line[SCRIPT_COMMAND_SIZE], command[SCRIPT_COMMAND_SIZE],
90 value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
91 value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
92 char *val_start, *tok;
93
94 if (fp != NULL) {
Dees_Troy6ed34b72013-01-25 15:01:29 +000095 DataManager::SetValue(TW_SIMULATE_ACTIONS, 0);
Dees_Troy6bdcbb12013-01-26 14:07:43 +000096 DataManager::SetValue("ui_progress", 0); // Reset the progress bar
Dees_Troy812660f2012-09-20 09:55:17 -040097 while (fgets(script_line, SCRIPT_COMMAND_SIZE, fp) != NULL && ret_val == 0) {
98 cindex = 0;
99 line_len = strlen(script_line);
100 if (line_len < 2)
101 continue; // there's a blank line or line is too short to contain a command
Dees_Troy2673cec2013-04-02 20:22:16 +0000102 //gui_print("script line: '%s'\n", script_line);
Dees_Troy812660f2012-09-20 09:55:17 -0400103 for (i=0; i<line_len; i++) {
104 if ((int)script_line[i] == 32) {
105 cindex = i;
106 i = line_len;
107 }
108 }
109 memset(command, 0, sizeof(command));
110 memset(value, 0, sizeof(value));
111 if ((int)script_line[line_len - 1] == 10)
112 remove_nl = 2;
113 else
114 remove_nl = 1;
115 if (cindex != 0) {
116 strncpy(command, script_line, cindex);
Matt Mowere96c3c32014-09-19 12:14:37 -0500117 LOGINFO("command is: '%s'\n", command);
Dees_Troy812660f2012-09-20 09:55:17 -0400118 val_start = script_line;
119 val_start += cindex + 1;
bigbiff bigbiffc03121d2013-09-09 19:14:35 -0400120 if ((int) *val_start == 32)
121 val_start++; //get rid of space
bigbiff bigbiff72e95542013-08-29 21:01:02 -0400122 if ((int) *val_start == 51)
123 val_start++; //get rid of = at the beginning
bigbiff bigbiffa6c5f4e2013-09-17 20:01:14 -0400124 if ((int) *val_start == 32)
125 val_start++; //get rid of space
Dees_Troy812660f2012-09-20 09:55:17 -0400126 strncpy(value, val_start, line_len - cindex - remove_nl);
Dees_Troy2673cec2013-04-02 20:22:16 +0000127 LOGINFO("value is: '%s'\n", value);
Dees_Troy812660f2012-09-20 09:55:17 -0400128 } else {
129 strncpy(command, script_line, line_len - remove_nl + 1);
Dees_Troy2673cec2013-04-02 20:22:16 +0000130 gui_print("command is: '%s' and there is no value\n", command);
Dees_Troy812660f2012-09-20 09:55:17 -0400131 }
132 if (strcmp(command, "install") == 0) {
Dees_Troy83a3b122012-10-01 14:16:43 -0400133 // Install Zip
Dees_Troy6ed34b72013-01-25 15:01:29 +0000134 DataManager::SetValue("tw_action_text2", "Installing Zip");
Dees_Troydc8bc1b2013-01-17 01:39:28 +0000135 PartitionManager.Mount_All_Storage();
Dees_Troy83a3b122012-10-01 14:16:43 -0400136 ret_val = Install_Command(value);
Dees_Troy06b4fe92012-10-16 11:43:20 -0400137 install_cmd = -1;
Dees_Troy812660f2012-09-20 09:55:17 -0400138 } else if (strcmp(command, "wipe") == 0) {
139 // Wipe
140 if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) {
Dees_Troy812660f2012-09-20 09:55:17 -0400141 PartitionManager.Wipe_By_Path("/cache");
Dees_Troy812660f2012-09-20 09:55:17 -0400142 } else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) {
Dees_Troy812660f2012-09-20 09:55:17 -0400143 PartitionManager.Wipe_Dalvik_Cache();
Dees_Troy812660f2012-09-20 09:55:17 -0400144 } else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) {
Dees_Troy812660f2012-09-20 09:55:17 -0400145 PartitionManager.Factory_Reset();
Dees_Troy812660f2012-09-20 09:55:17 -0400146 } else {
Dees_Troy2673cec2013-04-02 20:22:16 +0000147 LOGERR("Error with wipe command value: '%s'\n", value);
Dees_Troy812660f2012-09-20 09:55:17 -0400148 ret_val = 1;
149 }
150 } else if (strcmp(command, "backup") == 0) {
151 // Backup
Ethan Yonker74db1572015-10-28 12:44:49 -0500152 DataManager::SetValue("tw_action_text2", gui_parse_text("{@backing}"));
Dees_Troy812660f2012-09-20 09:55:17 -0400153 tok = strtok(value, " ");
154 strcpy(value1, tok);
155 tok = strtok(NULL, " ");
156 if (tok != NULL) {
157 memset(value2, 0, sizeof(value2));
158 strcpy(value2, tok);
159 line_len = strlen(tok);
160 if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13) {
161 if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13)
162 remove_nl = 2;
163 else
164 remove_nl = 1;
165 } else
166 remove_nl = 0;
167 strncpy(value2, tok, line_len - remove_nl);
Dees_Troy6ed34b72013-01-25 15:01:29 +0000168 DataManager::SetValue(TW_BACKUP_NAME, value2);
Ethan Yonker74db1572015-10-28 12:44:49 -0500169 gui_msg(Msg("backup_folder=Backup folder set to '{1}'")(value2));
Dees_Troyc9ff7a32012-09-27 10:09:41 -0400170 if (PartitionManager.Check_Backup_Name(true) != 0) {
171 ret_val = 1;
172 continue;
173 }
Dees_Troy812660f2012-09-20 09:55:17 -0400174 } else {
175 char empt[50];
176 strcpy(empt, "(Current Date)");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000177 DataManager::SetValue(TW_BACKUP_NAME, empt);
Dees_Troy812660f2012-09-20 09:55:17 -0400178 }
Dees_Troy83a3b122012-10-01 14:16:43 -0400179 ret_val = Backup_Command(value1);
Dees_Troy812660f2012-09-20 09:55:17 -0400180 } else if (strcmp(command, "restore") == 0) {
181 // Restore
Ethan Yonker74db1572015-10-28 12:44:49 -0500182 DataManager::SetValue("tw_action_text2", gui_parse_text("{@restore}"));
Dees_Troy812660f2012-09-20 09:55:17 -0400183 PartitionManager.Mount_All_Storage();
Dees_Troy6ed34b72013-01-25 15:01:29 +0000184 DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 0);
Dees_Troydc8bc1b2013-01-17 01:39:28 +0000185 char folder_path[512], partitions[512];
Dees_Troy812660f2012-09-20 09:55:17 -0400186
187 string val = value, restore_folder, restore_partitions;
188 size_t pos = val.find_last_of(" ");
189 if (pos == string::npos) {
Dees_Troydc8bc1b2013-01-17 01:39:28 +0000190 restore_folder = value;
191 partitions[0] = '\0';
192 } else {
193 restore_folder = val.substr(0, pos);
194 restore_partitions = val.substr(pos + 1, val.size() - pos - 1);
195 strcpy(partitions, restore_partitions.c_str());
Dees_Troy812660f2012-09-20 09:55:17 -0400196 }
Dees_Troy812660f2012-09-20 09:55:17 -0400197 strcpy(folder_path, restore_folder.c_str());
Dees_Troy2673cec2013-04-02 20:22:16 +0000198 LOGINFO("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions);
Ethan Yonker74db1572015-10-28 12:44:49 -0500199 gui_msg(Msg("restoring=Restoring {1}...")(folder_path));
Dees_Troy812660f2012-09-20 09:55:17 -0400200
201 if (folder_path[0] != '/') {
202 char backup_folder[512];
Dees_Troy6ed34b72013-01-25 15:01:29 +0000203 string folder_var;
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600204 std::vector<PartitionList> Storage_List;
205
206 PartitionManager.Get_Partition_List("storage", &Storage_List);
207 int listSize = Storage_List.size();
208 for (int i = 0; i < listSize; i++) {
209 if (PartitionManager.Is_Mounted_By_Path(Storage_List.at(i).Mount_Point)) {
210 DataManager::SetValue("tw_storage_path", Storage_List.at(i).Mount_Point);
Dees_Troy6ed34b72013-01-25 15:01:29 +0000211 DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var);
212 sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path);
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600213 if (TWFunc::Path_Exists(backup_folder)) {
214 strcpy(folder_path, backup_folder);
215 break;
216 }
Dees_Troy812660f2012-09-20 09:55:17 -0400217 }
218 }
Dees_Troy812660f2012-09-20 09:55:17 -0400219 } else {
220 if (folder_path[strlen(folder_path) - 1] == '/')
221 strcat(folder_path, ".");
222 else
223 strcat(folder_path, "/.");
224 }
225 if (!TWFunc::Path_Exists(folder_path)) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500226 gui_msg(Msg(msg::kError, "locate_backup_err=Unable to locate backup '{1}'")(folder_path));
Dees_Troy812660f2012-09-20 09:55:17 -0400227 ret_val = 1;
228 continue;
229 }
Dees_Troy6ed34b72013-01-25 15:01:29 +0000230 DataManager::SetValue("tw_restore", folder_path);
Dees_Troy812660f2012-09-20 09:55:17 -0400231
232 PartitionManager.Set_Restore_Files(folder_path);
Dees_Troya13d74f2013-03-24 08:54:55 -0500233 string Partition_List;
Dees_Troy83bd4832013-05-04 12:39:56 +0000234 int is_encrypted = 0;
235 DataManager::GetValue("tw_restore_encrypted", is_encrypted);
Dees_Troya13d74f2013-03-24 08:54:55 -0500236 DataManager::GetValue("tw_restore_list", Partition_List);
Dees_Troy812660f2012-09-20 09:55:17 -0400237 if (strlen(partitions) != 0) {
Dees_Troya13d74f2013-03-24 08:54:55 -0500238 string Restore_List;
Dees_Troy812660f2012-09-20 09:55:17 -0400239
240 memset(value2, 0, sizeof(value2));
241 strcpy(value2, partitions);
Ethan Yonker74db1572015-10-28 12:44:49 -0500242 gui_msg(Msg("set_restore_opt=Setting restore options: '{1}':")(value2));
Dees_Troy812660f2012-09-20 09:55:17 -0400243 line_len = strlen(value2);
244 for (i=0; i<line_len; i++) {
Dees_Troya13d74f2013-03-24 08:54:55 -0500245 if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find("/system;") != string::npos) {
246 Restore_List += "/system;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500247 gui_msg("system=System");
Dees_Troya13d74f2013-03-24 08:54:55 -0500248 } else if ((value2[i] == 'D' || value2[i] == 'd') && Partition_List.find("/data;") != string::npos) {
249 Restore_List += "/data;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500250 gui_msg("data=Data");
Dees_Troya13d74f2013-03-24 08:54:55 -0500251 } else if ((value2[i] == 'C' || value2[i] == 'c') && Partition_List.find("/cache;") != string::npos) {
252 Restore_List += "/cache;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500253 gui_msg("cache=Cache");
Dees_Troya13d74f2013-03-24 08:54:55 -0500254 } else if ((value2[i] == 'R' || value2[i] == 'r') && Partition_List.find("/recovery;") != string::npos) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500255 Restore_List += "/recovery;";
256 gui_msg("recovery=Recovery");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000257 } else if (value2[i] == '1' && DataManager::GetIntValue(TW_RESTORE_SP1_VAR) > 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000258 gui_print("%s\n", "Special1 -- No Longer Supported...");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000259 } else if (value2[i] == '2' && DataManager::GetIntValue(TW_RESTORE_SP2_VAR) > 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000260 gui_print("%s\n", "Special2 -- No Longer Supported...");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000261 } else if (value2[i] == '3' && DataManager::GetIntValue(TW_RESTORE_SP3_VAR) > 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000262 gui_print("%s\n", "Special3 -- No Longer Supported...");
Dees_Troya13d74f2013-03-24 08:54:55 -0500263 } else if ((value2[i] == 'B' || value2[i] == 'b') && Partition_List.find("/boot;") != string::npos) {
264 Restore_List += "/boot;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500265 gui_msg("boot=Boot");
Dees_Troya13d74f2013-03-24 08:54:55 -0500266 } else if ((value2[i] == 'A' || value2[i] == 'a') && Partition_List.find("/and-sec;") != string::npos) {
267 Restore_List += "/and-sec;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500268 gui_msg("android_secure=Android Secure");
Dees_Troya13d74f2013-03-24 08:54:55 -0500269 } else if ((value2[i] == 'E' || value2[i] == 'e') && Partition_List.find("/sd-ext;") != string::npos) {
270 Restore_List += "/sd-ext;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500271 gui_msg("sdext=SD-EXT");
Dees_Troy812660f2012-09-20 09:55:17 -0400272 } else if (value2[i] == 'M' || value2[i] == 'm') {
Dees_Troy6ed34b72013-01-25 15:01:29 +0000273 DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1);
Ethan Yonker74db1572015-10-28 12:44:49 -0500274 gui_msg("md5_check_skip=MD5 check skip is on");
Dees_Troy812660f2012-09-20 09:55:17 -0400275 }
276 }
277
Dees_Troya13d74f2013-03-24 08:54:55 -0500278 DataManager::SetValue("tw_restore_selected", Restore_List);
279 } else {
280 DataManager::SetValue("tw_restore_selected", Partition_List);
Dees_Troy812660f2012-09-20 09:55:17 -0400281 }
Dees_Troy83bd4832013-05-04 12:39:56 +0000282 if (is_encrypted) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500283 gui_err("ors_encrypt_restore_err=Unable to use OpenRecoveryScript to restore an encrypted backup.");
Dees_Troy83bd4832013-05-04 12:39:56 +0000284 ret_val = 1;
285 } else if (!PartitionManager.Run_Restore(folder_path))
Dees_Troya13d74f2013-03-24 08:54:55 -0500286 ret_val = 1;
287 else
Ethan Yonker74db1572015-10-28 12:44:49 -0500288 gui_msg("done=Done.");
Dees_Troy812660f2012-09-20 09:55:17 -0400289 } else if (strcmp(command, "mount") == 0) {
290 // Mount
Ethan Yonker74db1572015-10-28 12:44:49 -0500291 DataManager::SetValue("tw_action_text2", gui_parse_text("{@mounting}"));
Dees_Troy812660f2012-09-20 09:55:17 -0400292 if (value[0] != '/') {
293 strcpy(mount, "/");
294 strcat(mount, value);
295 } else
296 strcpy(mount, value);
297 if (PartitionManager.Mount_By_Path(mount, true))
Ethan Yonker74db1572015-10-28 12:44:49 -0500298 gui_msg(Msg("mounted=Mounted '{1}'")(mount));
Dees_Troy812660f2012-09-20 09:55:17 -0400299 } else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) {
300 // Unmount
Ethan Yonker74db1572015-10-28 12:44:49 -0500301 DataManager::SetValue("tw_action_text2", gui_parse_text("{@unmounting}"));
Dees_Troy812660f2012-09-20 09:55:17 -0400302 if (value[0] != '/') {
303 strcpy(mount, "/");
304 strcat(mount, value);
305 } else
306 strcpy(mount, value);
307 if (PartitionManager.UnMount_By_Path(mount, true))
Ethan Yonker74db1572015-10-28 12:44:49 -0500308 gui_msg(Msg("unmounted=Unounted '{1}'")(mount));
Dees_Troy812660f2012-09-20 09:55:17 -0400309 } else if (strcmp(command, "set") == 0) {
310 // Set value
Ethan Yonker6511c4d2015-06-17 16:52:29 -0500311 size_t len = strlen(value);
Dees_Troy812660f2012-09-20 09:55:17 -0400312 tok = strtok(value, " ");
313 strcpy(value1, tok);
Ethan Yonker6511c4d2015-06-17 16:52:29 -0500314 if (len > strlen(value1) + 1) {
315 char *val2 = value + strlen(value1) + 1;
Ethan Yonker74db1572015-10-28 12:44:49 -0500316 gui_msg(Msg("setting=Setting '{1}' to '{2}'")(value1)(val2));
Ethan Yonker6511c4d2015-06-17 16:52:29 -0500317 DataManager::SetValue(value1, val2);
318 } else {
Ethan Yonker74db1572015-10-28 12:44:49 -0500319 gui_msg(Msg("setting_empty=Setting '{1}' to empty")(value1));
Ethan Yonker6511c4d2015-06-17 16:52:29 -0500320 DataManager::SetValue(value1, "");
321 }
Dees_Troy812660f2012-09-20 09:55:17 -0400322 } else if (strcmp(command, "mkdir") == 0) {
323 // Make directory (recursive)
Ethan Yonker74db1572015-10-28 12:44:49 -0500324 DataManager::SetValue("tw_action_text2", gui_parse_text("{@making_dir1}"));
325 gui_msg(Msg("making_dir2=Making directory: '{1}'")(value));
thatf1408b32016-01-03 11:09:15 +0100326 if (!TWFunc::Recursive_Mkdir(value)) {
327 // error message already displayed by Recursive_Mkdir
Dees_Troy812660f2012-09-20 09:55:17 -0400328 ret_val = 1;
329 }
330 } else if (strcmp(command, "reboot") == 0) {
Ethan Yonker03a42f62014-08-08 11:03:51 -0500331 if (strlen(value) && strcmp(value, "recovery") == 0)
332 TWFunc::tw_reboot(rb_recovery);
333 else if (strlen(value) && strcmp(value, "poweroff") == 0)
334 TWFunc::tw_reboot(rb_poweroff);
335 else if (strlen(value) && strcmp(value, "bootloader") == 0)
336 TWFunc::tw_reboot(rb_bootloader);
337 else if (strlen(value) && strcmp(value, "download") == 0)
338 TWFunc::tw_reboot(rb_download);
339 else
340 TWFunc::tw_reboot(rb_system);
Dees_Troy812660f2012-09-20 09:55:17 -0400341 } else if (strcmp(command, "cmd") == 0) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500342 DataManager::SetValue("tw_action_text2", gui_parse_text("{@running_command}"));
Dees_Troy812660f2012-09-20 09:55:17 -0400343 if (cindex != 0) {
Vojtech Bocek05534202013-09-11 08:11:56 +0200344 TWFunc::Exec_Cmd(value);
Dees_Troy812660f2012-09-20 09:55:17 -0400345 } else {
Dees_Troy2673cec2013-04-02 20:22:16 +0000346 LOGERR("No value given for cmd\n");
Dees_Troy812660f2012-09-20 09:55:17 -0400347 }
348 } else if (strcmp(command, "print") == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000349 gui_print("%s\n", value);
Dees_Troy4fc00242013-01-17 19:22:12 +0000350 } else if (strcmp(command, "sideload") == 0) {
Dees_Troy4bc09ae2013-01-18 17:00:54 +0000351 // ADB Sideload
Ethan Yonker74db1572015-10-28 12:44:49 -0500352 DataManager::SetValue("tw_action_text2", gui_parse_text("{@sideload}"));
Dees_Troy6ed34b72013-01-25 15:01:29 +0000353 install_cmd = -1;
354
355 int wipe_cache = 0;
Ethan Yonkerd83587d2015-01-03 16:54:18 -0600356 string result;
357 pid_t sideload_child_pid;
Dees_Troy6ed34b72013-01-25 15:01:29 +0000358
Ethan Yonker74db1572015-10-28 12:44:49 -0500359 gui_msg("start_sideload=Starting ADB sideload feature...");
Ethan Yonkerd83587d2015-01-03 16:54:18 -0600360 ret_val = apply_from_adb("/", &sideload_child_pid);
361 if (ret_val != 0) {
362 if (ret_val == -2)
Ethan Yonker74db1572015-10-28 12:44:49 -0500363 gui_err("need_new_adb=You need adb 1.0.32 or newer to sideload to this device.");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000364 ret_val = 1; // failure
Ethan Yonkerd83587d2015-01-03 16:54:18 -0600365 } else if (TWinstall_zip(FUSE_SIDELOAD_HOST_PATHNAME, &wipe_cache) == 0) {
366 if (wipe_cache)
367 PartitionManager.Wipe_By_Path("/cache");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000368 } else {
Ethan Yonkerd83587d2015-01-03 16:54:18 -0600369 ret_val = 1; // failure
Dees_Troy4fc00242013-01-17 19:22:12 +0000370 }
Ethan Yonkerd83587d2015-01-03 16:54:18 -0600371 sideload = 1; // Causes device to go to the home screen afterwards
372 if (sideload_child_pid != 0) {
373 LOGINFO("Signaling child sideload process to exit.\n");
374 struct stat st;
375 // Calling stat() on this magic filename signals the minadbd
376 // subprocess to shut down.
377 stat(FUSE_SIDELOAD_HOST_EXIT_PATHNAME, &st);
378 int status;
379 LOGINFO("Waiting for child sideload process to exit.\n");
380 waitpid(sideload_child_pid, &status, 0);
381 }
Dees Troy28a85d22015-04-28 02:03:16 +0000382 property_set("ctl.start", "adbd");
Ethan Yonker74db1572015-10-28 12:44:49 -0500383 gui_msg("done=Done.");
Ethan Yonkeraae6e8c2014-02-11 21:37:36 -0600384 } else if (strcmp(command, "fixperms") == 0 || strcmp(command, "fixpermissions") == 0) {
385 ret_val = PartitionManager.Fix_Permissions();
386 if (ret_val != 0)
387 ret_val = 1; // failure
Ethan Yonker03a42f62014-08-08 11:03:51 -0500388 } else if (strcmp(command, "decrypt") == 0) {
389 if (*value) {
390 ret_val = PartitionManager.Decrypt_Device(value);
391 if (ret_val != 0)
392 ret_val = 1; // failure
393 } else {
Ethan Yonker74db1572015-10-28 12:44:49 -0500394 gui_err("no_pwd=No password provided.");
Ethan Yonker03a42f62014-08-08 11:03:51 -0500395 ret_val = 1; // failure
396 }
Dees_Troy812660f2012-09-20 09:55:17 -0400397 } else {
Dees_Troy2673cec2013-04-02 20:22:16 +0000398 LOGERR("Unrecognized script command: '%s'\n", command);
Dees_Troy812660f2012-09-20 09:55:17 -0400399 ret_val = 1;
400 }
401 }
402 fclose(fp);
that10ae24f2015-12-26 20:53:51 +0100403 unlink(SCRIPT_FILE_TMP);
Ethan Yonker74db1572015-10-28 12:44:49 -0500404 gui_msg("done_ors=Done processing script file");
Dees_Troy812660f2012-09-20 09:55:17 -0400405 } else {
Ethan Yonker74db1572015-10-28 12:44:49 -0500406 gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(SCRIPT_FILE_TMP)(strerror(errno)));
Dees_Troy812660f2012-09-20 09:55:17 -0400407 return 1;
408 }
Dees_Troy6ed34b72013-01-25 15:01:29 +0000409 if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500410 gui_msg("injecttwrp=Injecting TWRP into boot image...");
Dees_Troy06b4fe92012-10-16 11:43:20 -0400411 TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot");
412 if (Boot == NULL || Boot->Current_File_System != "emmc")
Vojtech Bocek05534202013-09-11 08:11:56 +0200413 TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash");
Dees_Troy06b4fe92012-10-16 11:43:20 -0400414 else {
415 string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
Vojtech Bocek05534202013-09-11 08:11:56 +0200416 TWFunc::Exec_Cmd(injectcmd.c_str());
Dees_Troy06b4fe92012-10-16 11:43:20 -0400417 }
Ethan Yonker74db1572015-10-28 12:44:49 -0500418 gui_msg("done=Done.");
Dees_Troy06b4fe92012-10-16 11:43:20 -0400419 }
Dees_Troy4bc09ae2013-01-18 17:00:54 +0000420 if (sideload)
421 ret_val = 1; // Forces booting to the home page after sideload
Dees_Troy812660f2012-09-20 09:55:17 -0400422 return ret_val;
423}
424
Dees_Troy01b6d0c2013-01-22 01:41:09 +0000425int OpenRecoveryScript::Insert_ORS_Command(string Command) {
xiaolu38c3aa72015-05-26 22:55:18 +0800426 ofstream ORSfile(SCRIPT_FILE_TMP, ios_base::app | ios_base::out);
Dees_Troy01b6d0c2013-01-22 01:41:09 +0000427 if (ORSfile.is_open()) {
428 //if (Command.substr(Command.size() - 1, 1) != "\n")
429 // Command += "\n";
Dees_Troy2673cec2013-04-02 20:22:16 +0000430 LOGINFO("Inserting '%s'\n", Command.c_str());
xiaolu38c3aa72015-05-26 22:55:18 +0800431 ORSfile << Command.c_str() << endl;
Dees_Troy01b6d0c2013-01-22 01:41:09 +0000432 ORSfile.close();
433 return 1;
434 }
Dees_Troy2673cec2013-04-02 20:22:16 +0000435 LOGERR("Unable to append '%s' to '%s'\n", Command.c_str(), SCRIPT_FILE_TMP);
Dees_Troy01b6d0c2013-01-22 01:41:09 +0000436 return 0;
437}
438
Dees_Troy83a3b122012-10-01 14:16:43 -0400439int OpenRecoveryScript::Install_Command(string Zip) {
440 // Install zip
441 string ret_string;
442 int ret_val = 0, wipe_cache = 0;
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600443 std::vector<PartitionList> Storage_List;
444 string Full_Path;
Dees_Troy83a3b122012-10-01 14:16:43 -0400445
Ethan Yonkeraee144c2015-02-11 16:49:19 -0600446 if (Zip.substr(0, 1) == "@") {
447 // This is a special file that contains a map of blocks on the data partition
448 Full_Path = Zip.substr(1);
449 if (!PartitionManager.Mount_By_Path(Full_Path, true) || !TWFunc::Path_Exists(Full_Path)) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500450 LOGINFO("Unable to install via mapped zip '%s'\n", Full_Path.c_str());
451 gui_msg(Msg(msg::kError, "zip_err=Error installing zip file '{1}'")(Zip));
Ethan Yonkeraee144c2015-02-11 16:49:19 -0600452 return 1;
453 }
Ethan Yonker74db1572015-10-28 12:44:49 -0500454 LOGINFO("Installing mapped zip file '%s'\n", Full_Path.c_str());
455 gui_msg(Msg("installing_zip=Installing zip file '{1}'")(Zip));
Ethan Yonkeraee144c2015-02-11 16:49:19 -0600456 } else if (!TWFunc::Path_Exists(Zip)) {
457 PartitionManager.Mount_All_Storage();
458 PartitionManager.Get_Partition_List("storage", &Storage_List);
459 int listSize = Storage_List.size();
460 for (int i = 0; i < listSize; i++) {
461 if (PartitionManager.Is_Mounted_By_Path(Storage_List.at(i).Mount_Point)) {
462 Full_Path = Storage_List.at(i).Mount_Point + "/" + Zip;
463 if (TWFunc::Path_Exists(Full_Path)) {
464 Zip = Full_Path;
465 break;
466 }
467 Full_Path = Zip;
468 LOGINFO("Trying to find zip '%s' on '%s'...\n", Full_Path.c_str(), Storage_List.at(i).Mount_Point.c_str());
469 ret_string = Locate_Zip_File(Full_Path, Storage_List.at(i).Mount_Point);
470 if (!ret_string.empty()) {
471 Zip = ret_string;
472 break;
473 }
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600474 }
Dees_Troy83a3b122012-10-01 14:16:43 -0400475 }
Ethan Yonkeraee144c2015-02-11 16:49:19 -0600476 if (!TWFunc::Path_Exists(Zip)) {
477 // zip file doesn't exist
478 gui_print("Unable to locate zip file '%s'.\n", Zip.c_str());
479 ret_val = 1;
480 } else
Ethan Yonker74db1572015-10-28 12:44:49 -0500481 gui_msg(Msg("installing_zip=Installing zip file '{1}'")(Zip));
Dees_Troy83a3b122012-10-01 14:16:43 -0400482 }
483
Ethan Yonkeraee144c2015-02-11 16:49:19 -0600484 ret_val = TWinstall_zip(Zip.c_str(), &wipe_cache);
Dees_Troy83a3b122012-10-01 14:16:43 -0400485 if (ret_val != 0) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500486 gui_msg(Msg(msg::kError, "zip_err=Error installing zip file '{1}'")(Zip));
Dees_Troy83a3b122012-10-01 14:16:43 -0400487 ret_val = 1;
488 } else if (wipe_cache)
489 PartitionManager.Wipe_By_Path("/cache");
490
491 return ret_val;
492}
493
Dees_Troy812660f2012-09-20 09:55:17 -0400494string OpenRecoveryScript::Locate_Zip_File(string Zip, string Storage_Root) {
495 string Path = TWFunc::Get_Path(Zip);
496 string File = TWFunc::Get_Filename(Zip);
497 string pathCpy = Path;
498 string wholePath;
499 size_t pos = Path.find("/", 1);
500
501 while (pos != string::npos)
502 {
503 pathCpy = Path.substr(pos, Path.size() - pos);
Matt Mowere96c3c32014-09-19 12:14:37 -0500504 wholePath = pathCpy + File;
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600505 LOGINFO("Looking for zip at '%s'\n", wholePath.c_str());
Dees_Troy812660f2012-09-20 09:55:17 -0400506 if (TWFunc::Path_Exists(wholePath))
507 return wholePath;
Matt Mowere96c3c32014-09-19 12:14:37 -0500508 wholePath = Storage_Root + wholePath;
Ethan Yonkerd7adf292014-02-15 16:43:23 -0600509 LOGINFO("Looking for zip at '%s'\n", wholePath.c_str());
Dees_Troy812660f2012-09-20 09:55:17 -0400510 if (TWFunc::Path_Exists(wholePath))
511 return wholePath;
512
513 pos = Path.find("/", pos + 1);
514 }
515 return "";
Dees_Troy83a3b122012-10-01 14:16:43 -0400516}
517
518int OpenRecoveryScript::Backup_Command(string Options) {
519 char value1[SCRIPT_COMMAND_SIZE];
520 int line_len, i;
Dees_Troya13d74f2013-03-24 08:54:55 -0500521 string Backup_List;
Dees_Troy83a3b122012-10-01 14:16:43 -0400522
523 strcpy(value1, Options.c_str());
524
Dees_Troy6ed34b72013-01-25 15:01:29 +0000525 DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0);
526 DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0);
Dees_Troy83a3b122012-10-01 14:16:43 -0400527
Ethan Yonker74db1572015-10-28 12:44:49 -0500528 gui_msg("select_backup_opt=Setting backup options:");
Dees_Troy83a3b122012-10-01 14:16:43 -0400529 line_len = Options.size();
530 for (i=0; i<line_len; i++) {
531 if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500532 Backup_List += "/system;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500533 gui_msg("system=System");
Dees_Troy83a3b122012-10-01 14:16:43 -0400534 } else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500535 Backup_List += "/data;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500536 gui_msg("data=Data");
Dees_Troy83a3b122012-10-01 14:16:43 -0400537 } else if (Options.substr(i, 1) == "C" || Options.substr(i, 1) == "c") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500538 Backup_List += "/cache;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500539 gui_msg("cache=Cache");
Dees_Troy83a3b122012-10-01 14:16:43 -0400540 } else if (Options.substr(i, 1) == "R" || Options.substr(i, 1) == "r") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500541 Backup_List += "/recovery;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500542 gui_msg("recovery=Recovery");
Dees_Troy83a3b122012-10-01 14:16:43 -0400543 } else if (Options.substr(i, 1) == "1") {
Dees_Troy2673cec2013-04-02 20:22:16 +0000544 gui_print("%s\n", "Special1 -- No Longer Supported...");
Dees_Troy83a3b122012-10-01 14:16:43 -0400545 } else if (Options.substr(i, 1) == "2") {
Dees_Troy2673cec2013-04-02 20:22:16 +0000546 gui_print("%s\n", "Special2 -- No Longer Supported...");
Dees_Troy83a3b122012-10-01 14:16:43 -0400547 } else if (Options.substr(i, 1) == "3") {
Dees_Troy2673cec2013-04-02 20:22:16 +0000548 gui_print("%s\n", "Special3 -- No Longer Supported...");
Dees_Troy83a3b122012-10-01 14:16:43 -0400549 } else if (Options.substr(i, 1) == "B" || Options.substr(i, 1) == "b") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500550 Backup_List += "/boot;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500551 gui_msg("boot=Boot");
Dees_Troy83a3b122012-10-01 14:16:43 -0400552 } else if (Options.substr(i, 1) == "A" || Options.substr(i, 1) == "a") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500553 Backup_List += "/and-sec;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500554 gui_msg("android_secure=Android Secure");
Dees_Troy83a3b122012-10-01 14:16:43 -0400555 } else if (Options.substr(i, 1) == "E" || Options.substr(i, 1) == "e") {
Dees_Troya13d74f2013-03-24 08:54:55 -0500556 Backup_List += "/sd-ext;";
Ethan Yonker74db1572015-10-28 12:44:49 -0500557 gui_msg("sdext=SD-EXT");
Dees_Troy83a3b122012-10-01 14:16:43 -0400558 } else if (Options.substr(i, 1) == "O" || Options.substr(i, 1) == "o") {
Dees_Troy6ed34b72013-01-25 15:01:29 +0000559 DataManager::SetValue(TW_USE_COMPRESSION_VAR, 1);
Ethan Yonker74db1572015-10-28 12:44:49 -0500560 gui_msg("compression_on=Compression is on");
Dees_Troy83a3b122012-10-01 14:16:43 -0400561 } else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") {
Dees_Troy6ed34b72013-01-25 15:01:29 +0000562 DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 1);
Ethan Yonker74db1572015-10-28 12:44:49 -0500563 gui_msg("md5_off=MD5 Generation is off");
Dees_Troy83a3b122012-10-01 14:16:43 -0400564 }
565 }
Dees_Troya13d74f2013-03-24 08:54:55 -0500566 DataManager::SetValue("tw_backup_list", Backup_List);
Dees_Troy83a3b122012-10-01 14:16:43 -0400567 if (!PartitionManager.Run_Backup()) {
Ethan Yonker74db1572015-10-28 12:44:49 -0500568 gui_err("backup_fail=Backup Failed");
Dees_Troy83a3b122012-10-01 14:16:43 -0400569 return 1;
570 }
Ethan Yonker74db1572015-10-28 12:44:49 -0500571 gui_msg("backup_complete=Backup complete!");
Dees_Troy83a3b122012-10-01 14:16:43 -0400572 return 0;
573}
Dees_Troy6ed34b72013-01-25 15:01:29 +0000574
that10ae24f2015-12-26 20:53:51 +0100575// this is called by main()
Dees_Troy6ed34b72013-01-25 15:01:29 +0000576void OpenRecoveryScript::Run_OpenRecoveryScript(void) {
577 DataManager::SetValue("tw_back", "main");
578 DataManager::SetValue("tw_action", "openrecoveryscript");
that10ae24f2015-12-26 20:53:51 +0100579 DataManager::SetValue("tw_action_param", "");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000580 DataManager::SetValue("tw_has_action2", "0");
581 DataManager::SetValue("tw_action2", "");
582 DataManager::SetValue("tw_action2_param", "");
Ethan Yonker89583ef2015-08-26 09:01:59 -0500583#ifdef TW_OEM_BUILD
Ethan Yonker74db1572015-10-28 12:44:49 -0500584 DataManager::SetValue("tw_action_text1", gui_lookup("running_recovery_commands", "Running Recovery Commands"));
585 DataManager::SetValue("tw_complete_text1", gui_lookup("recovery_commands_complete", "Recovery Commands Complete"));
Ethan Yonker89583ef2015-08-26 09:01:59 -0500586#else
Ethan Yonker74db1572015-10-28 12:44:49 -0500587 DataManager::SetValue("tw_action_text1", gui_lookup("running_ors", "Running OpenRecoveryScript"));
588 DataManager::SetValue("tw_complete_text1", gui_lookup("ors_complete", "OpenRecoveryScript Complete"));
Ethan Yonker89583ef2015-08-26 09:01:59 -0500589#endif
590 DataManager::SetValue("tw_action_text2", "");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000591 DataManager::SetValue("tw_has_cancel", 0);
592 DataManager::SetValue("tw_show_reboot", 0);
Ethan Yonkerfd0439e2015-01-14 11:08:13 -0600593 if (gui_startPage("action_page", 0, 1) != 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000594 LOGERR("Failed to load OpenRecoveryScript GUI page.\n");
Dees_Troy6ed34b72013-01-25 15:01:29 +0000595 }
Dees_Troy6bdcbb12013-01-26 14:07:43 +0000596}
that10ae24f2015-12-26 20:53:51 +0100597
598// this is called by the "openrecoveryscript" GUI action called via action page from Run_OpenRecoveryScript
599int OpenRecoveryScript::Run_OpenRecoveryScript_Action() {
600 int op_status = 1;
601 // Check for the SCRIPT_FILE_TMP first as these are AOSP recovery commands
602 // that we converted to ORS commands during boot in recovery.cpp.
603 // Run those first.
604 int reboot = 0;
605 if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
606 gui_msg("running_recovery_commands=Running Recovery Commands");
607 if (OpenRecoveryScript::run_script_file() == 0) {
608 reboot = 1;
609 op_status = 0;
610 }
611 }
612 // Check for the ORS file in /cache and attempt to run those commands.
613 if (OpenRecoveryScript::check_for_script_file()) {
614 gui_msg("running_ors=Running OpenRecoveryScript");
615 if (OpenRecoveryScript::run_script_file() == 0) {
616 reboot = 1;
617 op_status = 0;
618 }
619 }
620 if (reboot) {
621 // Disable stock recovery reflashing
622 TWFunc::Disable_Stock_Recovery_Replace();
623 usleep(2000000); // Sleep for 2 seconds before rebooting
624 TWFunc::tw_reboot(rb_system);
625 usleep(5000000); // Sleep for 5 seconds to allow reboot to occur
626 } else {
627 DataManager::SetValue("tw_page_done", 1);
628 }
629 return op_status;
630}
631
632// this is called by the "twcmd" GUI action when a command is received via FIFO from the "twrp" command line tool
633void OpenRecoveryScript::Run_CLI_Command(const char* command) {
634 if (strlen(command) > 11 && strncmp(command, "runscript", 9) == 0) {
635 const char* filename = command + 10;
636 if (OpenRecoveryScript::copy_script_file(filename) == 0) {
637 LOGINFO("Unable to copy script file\n");
638 } else {
639 OpenRecoveryScript::run_script_file();
640 }
641 } else if (strlen(command) > 5 && strncmp(command, "get", 3) == 0) {
642 const char* varname = command + 4;
643 string value;
644 DataManager::GetValue(varname, value);
645 gui_print("%s = %s\n", varname, value.c_str());
646 } else if (strlen(command) > 9 && strncmp(command, "decrypt", 7) == 0) {
647 const char* pass = command + 8;
648 gui_msg("decrypt_cmd=Attempting to decrypt data partition via command line.");
649 if (PartitionManager.Decrypt_Device(pass) == 0) {
650 // set_page_done = 1; // done by singleaction_page anyway
651 }
652 } else if (OpenRecoveryScript::Insert_ORS_Command(command)) {
653 OpenRecoveryScript::run_script_file();
654 }
655
656 // let the GUI close the output fd and restart the command listener
657 call_after_cli_command();
658 LOGINFO("Done reading ORS command from command line\n");
659}