summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/action.cpp60
-rw-r--r--gui/objects.hpp1
2 files changed, 39 insertions, 22 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 361a676b2..ef325aa4f 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1378,34 +1378,50 @@ int GUIAction::adbsideloadcancel(std::string arg)
return 0;
}
+void* GUIAction::openrecoveryscript_thread_fn(void *cookie)
+{
+ GUIAction* this_ = (GUIAction*) cookie;
+
+ // Check for the SCRIPT_FILE_TMP first as these are AOSP recovery commands
+ // that we converted to ORS commands during boot in recovery.cpp.
+ // Run those first.
+ int reboot = 0;
+ if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
+ gui_print("Processing AOSP recovery commands...\n");
+ if (OpenRecoveryScript::run_script_file() == 0) {
+ reboot = 1;
+ }
+ }
+ // Check for the ORS file in /cache and attempt to run those commands.
+ if (OpenRecoveryScript::check_for_script_file()) {
+ gui_print("Processing OpenRecoveryScript file...\n");
+ if (OpenRecoveryScript::run_script_file() == 0) {
+ reboot = 1;
+ }
+ }
+ if (reboot) {
+ usleep(2000000); // Sleep for 2 seconds before rebooting
+ TWFunc::tw_reboot(rb_system);
+ } else {
+ DataManager::SetValue("tw_page_done", 1);
+ }
+ this_->operation_end(1);
+ return NULL;
+}
+
int GUIAction::openrecoveryscript(std::string arg)
{
operation_start("OpenRecoveryScript");
if (simulate) {
simulate_progress_bar();
+ operation_end(0);
} else {
- // Check for the SCRIPT_FILE_TMP first as these are AOSP recovery commands
- // that we converted to ORS commands during boot in recovery.cpp.
- // Run those first.
- int reboot = 0;
- if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
- gui_print("Processing AOSP recovery commands...\n");
- if (OpenRecoveryScript::run_script_file() == 0) {
- reboot = 1;
- }
- }
- // Check for the ORS file in /cache and attempt to run those commands.
- if (OpenRecoveryScript::check_for_script_file()) {
- gui_print("Processing OpenRecoveryScript file...\n");
- if (OpenRecoveryScript::run_script_file() == 0) {
- reboot = 1;
- }
- }
- if (reboot) {
- usleep(2000000); // Sleep for 2 seconds before rebooting
- TWFunc::tw_reboot(rb_system);
- } else {
- DataManager::SetValue("tw_page_done", 1);
+ // we need to start a thread to allow the action page to display properly
+ pthread_t openrecoveryscript_thread;
+ int rc = pthread_create(&openrecoveryscript_thread, NULL, openrecoveryscript_thread_fn, this);
+ if (rc != 0) {
+ LOGERR("Error starting sideload thread, rc=%i.\n", rc);
+ operation_end(1);
}
}
return 0;
diff --git a/gui/objects.hpp b/gui/objects.hpp
index bf07c86bc..124c9264d 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -288,6 +288,7 @@ protected:
void operation_end(const int operation_status);
static void* command_thread(void *cookie);
static void* sideload_thread_fn(void *cookie);
+ static void* openrecoveryscript_thread_fn(void *cookie);
time_t Start;
// map action name to function pointer