From c9ecd4473c5763fe6c372e6fead1cc1f6b7714cf Mon Sep 17 00:00:00 2001 From: Ricardo Gomez Date: Fri, 5 Jul 2013 16:13:52 -0700 Subject: Add a TW_NO_TIMEOUT option Change-Id: Ifb3a5bd9f1e6c2e9810c90b0aec198e91d5956fc --- Android.mk | 3 +++ data.cpp | 26 +++++++++++++++++++++----- gui/Android.mk | 3 +++ gui/action.cpp | 7 ++++++- gui/devices/1024x600/res/ui.xml | 3 +++ gui/devices/1024x768/res/ui.xml | 3 +++ gui/devices/1080x1920/res/ui.xml | 3 +++ gui/devices/1280x800/res/ui.xml | 3 +++ gui/devices/1920x1200/res/ui.xml | 3 +++ gui/devices/2560x1600/res/ui.xml | 3 +++ gui/devices/320x480/res/ui.xml | 3 +++ gui/devices/480x800/res/ui.xml | 3 +++ gui/devices/480x854/res/ui.xml | 3 +++ gui/devices/540x960/res/ui.xml | 3 +++ gui/devices/720x1280/res/ui.xml | 3 +++ gui/devices/800x1280/res/ui.xml | 3 +++ gui/devices/800x480/res/ui.xml | 3 +++ gui/gui.cpp | 30 ++++++++++++++++++++++++++++++ gui/pages.cpp | 7 ++++++- variables.h | 2 +- 20 files changed, 109 insertions(+), 8 deletions(-) diff --git a/Android.mk b/Android.mk index a6a82ef26..9ef4e67bd 100644 --- a/Android.mk +++ b/Android.mk @@ -99,6 +99,9 @@ endif LOCAL_C_INCLUDES += system/extras/ext4_utils #TWRP Build Flags +ifneq ($(TW_NO_SCREEN_TIMEOUT),) + LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT +endif ifeq ($(BOARD_HAS_NO_REAL_SDCARD), true) LOCAL_CFLAGS += -DBOARD_HAS_NO_REAL_SDCARD endif diff --git a/data.cpp b/data.cpp index c028897e6..be76592aa 100644 --- a/data.cpp +++ b/data.cpp @@ -40,7 +40,9 @@ #include "data.hpp" #include "partitions.hpp" #include "twrp-functions.hpp" +#ifndef TW_NO_SCREEN_TIMEOUT #include "gui/blanktimer.hpp" +#endif #ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID #include "cutils/properties.h" @@ -59,11 +61,13 @@ extern "C" using namespace std; -map DataManager::mValues; -map DataManager::mConstValues; -string DataManager::mBackingFile; -int DataManager::mInitialized = 0; +map DataManager::mValues; +map DataManager::mConstValues; +string DataManager::mBackingFile; +int DataManager::mInitialized = 0; +#ifndef TW_NO_SCREEN_TIMEOUT extern blanktimer blankTimer; +#endif // Device ID functions void DataManager::sanitize_device_id(char* device_id) { @@ -264,8 +268,10 @@ int DataManager::LoadValues(const string filename) } else mValues.insert(TNameValuePair(Name, TStrIntPair(Value, 1))); +#ifndef TW_NO_SCREEN_TIMEOUT if (Name == "tw_screen_timeout_secs") blankTimer.setTime(atoi(Value.c_str())); +#endif } error: fclose(in); @@ -445,9 +451,13 @@ int DataManager::SetValue(const string varName, string value, int persist /* = 0 if (pos->second.second != 0) SaveValues(); + +#ifndef TW_NO_SCREEN_TIMEOUT if (varName == "tw_screen_timeout_secs") { blankTimer.setTime(atoi(value.c_str())); - } else if (varName == "tw_storage_path") { + } else +#endif + if (varName == "tw_storage_path") { SetBackupFolder(); } gui_notifyVarChange(varName.c_str(), value.c_str()); @@ -911,7 +921,13 @@ void DataManager::SetDefaultValues() mValues.insert(make_pair("tw_background_thread_running", make_pair("0", 0))); mValues.insert(make_pair(TW_RESTORE_FILE_DATE, make_pair("0", 0))); mValues.insert(make_pair("tw_military_time", make_pair("0", 1))); +#ifdef TW_NO_SCREEN_TIMEOUT + mValues.insert(make_pair("tw_screen_timeout_secs", make_pair("0", 1))); + mValues.insert(make_pair("tw_no_screen_timeout", make_pair("1", 1))); +#else mValues.insert(make_pair("tw_screen_timeout_secs", make_pair("60", 1))); + mValues.insert(make_pair("tw_no_screen_timeout", make_pair("0", 1))); +#endif mValues.insert(make_pair("tw_gui_done", make_pair("0", 0))); mValues.insert(make_pair("tw_encrypt_backup", make_pair("0", 0))); #ifdef TW_BRIGHTNESS_PATH diff --git a/gui/Android.mk b/gui/Android.mk index 7ac4bac9b..18decd047 100644 --- a/gui/Android.mk +++ b/gui/Android.mk @@ -61,6 +61,9 @@ endif ifneq ($(TW_NO_SCREEN_BLANK),) LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK endif +ifneq ($(TW_NO_SCREEN_TIMEOUT),) + LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT +endif LOCAL_C_INCLUDES += bionic external/stlport/stlport $(commands_recovery_local_path)/gui/devices/$(DEVICE_RESOLUTION) diff --git a/gui/action.cpp b/gui/action.cpp index ee3373154..d67e697b0 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -40,8 +40,9 @@ #include "../openrecoveryscript.hpp" #include "../adb_install.h" +#ifndef TW_NO_SCREEN_TIMEOUT #include "blanktimer.hpp" - +#endif extern "C" { #include "../twcommon.h" #include "../minuitwrp/minui.h" @@ -59,7 +60,9 @@ int gui_start(); #include "rapidxml.hpp" #include "objects.hpp" +#ifndef TW_NO_SCREEN_TIMEOUT extern blanktimer blankTimer; +#endif void curtainClose(void); @@ -339,7 +342,9 @@ void GUIAction::operation_end(const int operation_status, const int simulate) } DataManager::SetValue("tw_operation_state", 1); DataManager::SetValue(TW_ACTION_BUSY, 0); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } int GUIAction::doAction(Action action, int isThreaded /* = 0 */) diff --git a/gui/devices/1024x600/res/ui.xml b/gui/devices/1024x600/res/ui.xml index 5979c50b0..2b7d20e2e 100755 --- a/gui/devices/1024x600/res/ui.xml +++ b/gui/devices/1024x600/res/ui.xml @@ -2587,6 +2587,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2596,6 +2597,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2603,6 +2605,7 @@ + diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml index 86cfddab4..b625174a4 100644 --- a/gui/devices/1024x768/res/ui.xml +++ b/gui/devices/1024x768/res/ui.xml @@ -2587,6 +2587,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2596,6 +2597,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2603,6 +2605,7 @@ + diff --git a/gui/devices/1080x1920/res/ui.xml b/gui/devices/1080x1920/res/ui.xml index e23086ac4..29c8bc303 100644 --- a/gui/devices/1080x1920/res/ui.xml +++ b/gui/devices/1080x1920/res/ui.xml @@ -2598,6 +2598,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2607,6 +2608,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2614,6 +2616,7 @@ + diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml index 4a066a3b1..b86f99171 100644 --- a/gui/devices/1280x800/res/ui.xml +++ b/gui/devices/1280x800/res/ui.xml @@ -2587,6 +2587,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2596,6 +2597,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2603,6 +2605,7 @@ + diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml index 458a72371..157005f1a 100644 --- a/gui/devices/1920x1200/res/ui.xml +++ b/gui/devices/1920x1200/res/ui.xml @@ -2587,6 +2587,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2596,6 +2597,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2603,6 +2605,7 @@ + diff --git a/gui/devices/2560x1600/res/ui.xml b/gui/devices/2560x1600/res/ui.xml index 6a77a4fc1..3d6b65f5c 100644 --- a/gui/devices/2560x1600/res/ui.xml +++ b/gui/devices/2560x1600/res/ui.xml @@ -2587,6 +2587,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2596,6 +2597,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2603,6 +2605,7 @@ + diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml index 041a1356b..0719a942c 100644 --- a/gui/devices/320x480/res/ui.xml +++ b/gui/devices/320x480/res/ui.xml @@ -2585,6 +2585,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2594,6 +2595,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2601,6 +2603,7 @@ + diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml index 2b428b40e..b7b527bb9 100644 --- a/gui/devices/480x800/res/ui.xml +++ b/gui/devices/480x800/res/ui.xml @@ -2585,6 +2585,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2594,6 +2595,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2601,6 +2603,7 @@ + diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml index f8d6da167..cb6577f20 100644 --- a/gui/devices/480x854/res/ui.xml +++ b/gui/devices/480x854/res/ui.xml @@ -2584,6 +2584,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2593,6 +2594,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2600,6 +2602,7 @@ + diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml index 7448ddf6e..078f1ae51 100644 --- a/gui/devices/540x960/res/ui.xml +++ b/gui/devices/540x960/res/ui.xml @@ -2585,6 +2585,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2594,6 +2595,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2601,6 +2603,7 @@ + diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml index 2319c555b..d2896cc94 100644 --- a/gui/devices/720x1280/res/ui.xml +++ b/gui/devices/720x1280/res/ui.xml @@ -2598,6 +2598,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2607,6 +2608,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2614,6 +2616,7 @@ + diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml index 692c736c7..ba7dba321 100755 --- a/gui/devices/800x1280/res/ui.xml +++ b/gui/devices/800x1280/res/ui.xml @@ -2586,6 +2586,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2595,6 +2596,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2602,6 +2604,7 @@ + diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml index 768f246f1..ba262bcce 100755 --- a/gui/devices/800x480/res/ui.xml +++ b/gui/devices/800x480/res/ui.xml @@ -2595,6 +2595,7 @@ + Enable screen timeout. tw_screen_timeout_secs=60 @@ -2604,6 +2605,7 @@ + Enable screen timeout. tw_screen_timeout_secs=0 @@ -2611,6 +2613,7 @@ + diff --git a/gui/gui.cpp b/gui/gui.cpp index 821c7f5b2..6ee29d57b 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -47,7 +47,9 @@ extern "C" #include "../variables.h" #include "../partitions.hpp" #include "../twrp-functions.hpp" +#ifndef TW_NO_SCREEN_TIMEOUT #include "blanktimer.hpp" +#endif const static int CURTAIN_FADE = 32; @@ -62,7 +64,9 @@ static int gForceRender = 0; pthread_mutex_t gForceRendermutex; static int gNoAnimation = 1; static int gGuiInputRunning = 0; +#ifndef TW_NO_SCREEN_TIMEOUT blanktimer blankTimer; +#endif // Needed by pages.cpp too int gGuiRunning = 0; @@ -167,6 +171,7 @@ void curtainClose() static void * input_thread(void *cookie) { + int drag = 0; static int touch_and_hold = 0, dontwait = 0; static int touch_repeat = 0, key_repeat = 0; @@ -176,10 +181,14 @@ static void * input_thread(void *cookie) HardwareKeyboard kb; string seconds; +#ifndef TW_NO_SCREEN_TIMEOUT //start screen timeout threads blankTimer.setTimerThread(); DataManager::GetValue("tw_screen_timeout_secs", seconds); blankTimer.setTime(atoi(seconds.c_str())); +#else + LOGINFO("Skipping screen timeout threads: TW_NO_SCREEN_TIMEOUT is set\n"); +#endif for (;;) { @@ -208,7 +217,9 @@ static void * input_thread(void *cookie) LOGERR("TOUCH_HOLD: %d,%d\n", x, y); #endif PageManager::NotifyTouch(TOUCH_HOLD, x, y); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } else if (touch_repeat && mtime > 100) { @@ -217,7 +228,9 @@ static void * input_thread(void *cookie) #endif gettimeofday(&touchStart, NULL); PageManager::NotifyTouch(TOUCH_REPEAT, x, y); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } else if (key_repeat == 1 && mtime > 500) { @@ -227,7 +240,10 @@ static void * input_thread(void *cookie) gettimeofday(&touchStart, NULL); key_repeat = 2; kb.KeyRepeat(); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif + } else if (key_repeat == 2 && mtime > 100) { @@ -236,7 +252,9 @@ static void * input_thread(void *cookie) #endif gettimeofday(&touchStart, NULL); kb.KeyRepeat(); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } } else if (ev.type == EV_ABS) @@ -253,7 +271,9 @@ static void * input_thread(void *cookie) LOGERR("TOUCH_RELEASE: %d,%d\n", x, y); #endif PageManager::NotifyTouch(TOUCH_RELEASE, x, y); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif touch_and_hold = 0; touch_repeat = 0; if (!key_repeat) @@ -276,7 +296,9 @@ static void * input_thread(void *cookie) dontwait = 1; key_repeat = 0; gettimeofday(&touchStart, NULL); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } else { @@ -288,7 +310,9 @@ static void * input_thread(void *cookie) if (PageManager::NotifyTouch(TOUCH_DRAG, x, y) > 0) state = 1; key_repeat = 0; +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } } } @@ -309,7 +333,9 @@ static void * input_thread(void *cookie) touch_repeat = 0; dontwait = 1; gettimeofday(&touchStart, NULL); +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } else { @@ -317,7 +343,9 @@ static void * input_thread(void *cookie) touch_and_hold = 0; touch_repeat = 0; dontwait = 0; +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } } else @@ -328,7 +356,9 @@ static void * input_thread(void *cookie) touch_and_hold = 0; touch_repeat = 0; dontwait = 0; +#ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); +#endif } } } diff --git a/gui/pages.cpp b/gui/pages.cpp index 9aea1b85a..2bb70e170 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -41,10 +41,14 @@ extern "C" { #include "rapidxml.hpp" #include "objects.hpp" +#ifndef TW_NO_SCREEN_TIMEOUT #include "blanktimer.hpp" +#endif extern int gGuiRunning; +#ifndef TW_NO_SCREEN_TIMEOUT extern blanktimer blankTimer; +#endif std::map PageManager::mPageSets; PageSet* PageManager::mCurrentSet; @@ -919,9 +923,10 @@ int PageManager::Render(void) int PageManager::Update(void) { +#ifndef TW_NO_SCREEN_TIMEOUT if(blankTimer.IsScreenOff()) return 0; - +#endif return (mCurrentSet ? mCurrentSet->Update() : -1); } diff --git a/variables.h b/variables.h index 4020b7599..b8a938035 100644 --- a/variables.h +++ b/variables.h @@ -17,7 +17,7 @@ #ifndef _VARIABLES_HEADER_ #define _VARIABLES_HEADER_ -#define TW_VERSION_STR "2.6.0.0" +#define TW_VERSION_STR "2.6.0.4" #define TW_USE_COMPRESSION_VAR "tw_use_compression" #define TW_FILENAME "tw_filename" -- cgit v1.2.3