summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-01-03 23:13:06 +0100
committerEthan Yonker <dees_troy@teamw.in>2015-01-05 02:41:10 +0100
commit24e7eb73cea323c959c93cbe3130774a97b3c501 (patch)
treef99f661ae3f22103cde697605334f860a6ba89ce
parentfix adb sideload (diff)
downloadandroid_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar.gz
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar.bz2
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar.lz
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar.xz
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.tar.zst
android_bootable_recovery-24e7eb73cea323c959c93cbe3130774a97b3c501.zip
-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