diff options
author | Dees_Troy <dees_troy@teamw.in> | 2013-01-18 18:00:54 +0100 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2013-01-18 18:07:31 +0100 |
commit | 4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540 (patch) | |
tree | 222331d15467e2167212fee37ce1eecf3107986f /gui | |
parent | Save version to cache (diff) | |
download | android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar.gz android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar.bz2 android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar.lz android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar.xz android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.tar.zst android_bootable_recovery-4bc09ae4361b6fc1f1a5044ea102e3fe6f3ce540.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/action.cpp | 6 | ||||
-rw-r--r-- | gui/gui.cpp | 80 | ||||
-rw-r--r-- | gui/gui.h | 1 |
3 files changed, 82 insertions, 5 deletions
diff --git a/gui/action.cpp b/gui/action.cpp index 1f3647d16..14ef71609 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -253,9 +253,8 @@ int GUIAction::doActions() LOGE("Error setting pthread_attr_setstacksize\n"); return -1; } - LOGI("creating thread\n"); + LOGI("Creating thread\n"); int ret = pthread_create(&t, &tattr, thread_start, this); - LOGI("after thread creation\n"); if (ret) { LOGE("Unable to create more threads for actions... continuing in same thread! %i\n", ret); thread_start(this); @@ -1071,6 +1070,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) string result, Sideload_File; if (!PartitionManager.Mount_Current_Storage(true)) { + DataManager::SetValue("tw_page_done", "1"); // For OpenRecoveryScript support operation_end(1, simulate); return 0; } @@ -1101,6 +1101,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) } } } + DataManager::SetValue("tw_page_done", "1"); // For OpenRecoveryScript support operation_end(ret, simulate); return 0; } @@ -1113,6 +1114,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) DataManager::GetValue("tw_child_pid", child_pid); ui_print("Cancelling ADB sideload...\n"); kill(child_pid, SIGTERM); + DataManager::SetValue("tw_page_done", "1"); // For OpenRecoveryScript support return 0; } } diff --git a/gui/gui.cpp b/gui/gui.cpp index e128337b5..c431d8fe0 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -60,6 +60,7 @@ static int gGuiConsoleRunning = 0; static int gGuiConsoleTerminate = 0; static int gForceRender = 0; static int gNoAnimation = 1; +static int gGuiInputRunning = 0; // Needed by pages.cpp too int gGuiRunning = 0; @@ -391,6 +392,56 @@ static int runPages(void) return 0; } +static int runPage(const char* page_name) +{ + gui_changePage(page_name); + + // Raise the curtain + if (gCurtain != NULL) + { + gr_surface surface; + + PageManager::Render(); + gr_get_surface(&surface); + curtainRaise(surface); + gr_free_surface(surface); + } + + gGuiRunning = 1; + + DataManager::SetValue("tw_loaded", 1); + + for (;;) + { + loopTimer(); + + if (!gForceRender) + { + int ret; + + ret = PageManager::Update(); + if (ret > 1) + PageManager::Render(); + + if (ret > 0) + flip(); + } + else + { + gForceRender = 0; + PageManager::Render(); + flip(); + } + if (DataManager::GetIntValue("tw_page_done") != 0) { + gui_changePage("main"); + break; + } + } + + gGuiRunning = 0; + return 0; +} + int gui_forceRender(void) { gForceRender = 1; @@ -537,13 +588,36 @@ extern "C" int gui_start() // Set the default package PageManager::SelectPackage("TWRP"); - // Start by spinning off an input handler. - pthread_t t; - pthread_create(&t, NULL, input_thread, NULL); + if (!gGuiInputRunning) { + // Start by spinning off an input handler. + pthread_t t; + pthread_create(&t, NULL, input_thread, NULL); + gGuiInputRunning = 1; + } return runPages(); } +extern "C" int gui_startPage(const char* page_name) +{ + if (!gGuiInitialized) return -1; + + gGuiConsoleTerminate = 1; + while (gGuiConsoleRunning) loopTimer(); + + // Set the default package + PageManager::SelectPackage("TWRP"); + + if (!gGuiInputRunning) { + // Start by spinning off an input handler. + pthread_t t; + pthread_create(&t, NULL, input_thread, NULL); + gGuiInputRunning = 1; + } + + return runPage(page_name); +} + static void *console_thread(void *cookie) { PageManager::SwitchToConsole(); @@ -5,6 +5,7 @@ int gui_console_only(); int gui_init(); int gui_loadResources(); int gui_start(); +int gui_startPage(const char* page_name); void gui_print(const char *fmt, ...); void gui_print_overwrite(const char *fmt, ...); |