summaryrefslogtreecommitdiffstats
path: root/openrecoveryscript.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-08-08 18:03:51 +0200
committerEthan Yonker <dees_troy@teamw.in>2014-08-09 14:49:35 +0200
commit03a42f6c6afc69919544c6dbe0fce49637ec17df (patch)
treef47a227f97e67e0ce61d00b6cea427aa0c59de95 /openrecoveryscript.cpp
parentSet font based on resolution if not set already (diff)
downloadandroid_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar.gz
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar.bz2
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar.lz
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar.xz
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.tar.zst
android_bootable_recovery-03a42f6c6afc69919544c6dbe0fce49637ec17df.zip
Diffstat (limited to 'openrecoveryscript.cpp')
-rw-r--r--openrecoveryscript.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index 014702741..1461f2d88 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -60,6 +60,20 @@ int OpenRecoveryScript::check_for_script_file(void) {
return 0;
}
+int OpenRecoveryScript::copy_script_file(string filename) {
+ if (TWFunc::Path_Exists(filename)) {
+ LOGINFO("Script file found: '%s'\n", filename.c_str());
+ if (filename == SCRIPT_FILE_TMP)
+ return 1; // file is already in the right place
+ // Copy script file to /tmp
+ TWFunc::copy_file(filename, SCRIPT_FILE_TMP, 0755);
+ // Delete the old file
+ unlink(filename.c_str());
+ return 1;
+ }
+ return 0;
+}
+
int OpenRecoveryScript::run_script_file(void) {
FILE *fp = fopen(SCRIPT_FILE_TMP, "r");
int ret_val = 0, cindex, line_len, i, remove_nl, install_cmd = 0, sideload = 0;
@@ -305,7 +319,16 @@ int OpenRecoveryScript::run_script_file(void) {
ret_val = 1;
}
} else if (strcmp(command, "reboot") == 0) {
- // Reboot
+ if (strlen(value) && strcmp(value, "recovery") == 0)
+ TWFunc::tw_reboot(rb_recovery);
+ else if (strlen(value) && strcmp(value, "poweroff") == 0)
+ TWFunc::tw_reboot(rb_poweroff);
+ else if (strlen(value) && strcmp(value, "bootloader") == 0)
+ TWFunc::tw_reboot(rb_bootloader);
+ else if (strlen(value) && strcmp(value, "download") == 0)
+ TWFunc::tw_reboot(rb_download);
+ else
+ TWFunc::tw_reboot(rb_system);
} else if (strcmp(command, "cmd") == 0) {
DataManager::SetValue("tw_action_text2", "Running Command");
if (cindex != 0) {
@@ -350,6 +373,15 @@ int OpenRecoveryScript::run_script_file(void) {
ret_val = PartitionManager.Fix_Permissions();
if (ret_val != 0)
ret_val = 1; // failure
+ } else if (strcmp(command, "decrypt") == 0) {
+ if (*value) {
+ ret_val = PartitionManager.Decrypt_Device(value);
+ if (ret_val != 0)
+ ret_val = 1; // failure
+ } else {
+ LOGERR("No password provided.\n");
+ ret_val = 1; // failure
+ }
} else {
LOGERR("Unrecognized script command: '%s'\n", command);
ret_val = 1;