Add a TW_NO_TIMEOUT option

Change-Id: Ifb3a5bd9f1e6c2e9810c90b0aec198e91d5956fc
diff --git a/Android.mk b/Android.mk
index a6a82ef..9ef4e67 100644
--- a/Android.mk
+++ b/Android.mk
@@ -99,6 +99,9 @@
 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 c028897..be76592 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 @@
 
 using namespace std;
 
-map<string, DataManager::TStrIntPair>	DataManager::mValues;
-map<string, string>					 	DataManager::mConstValues;
-string									DataManager::mBackingFile;
-int										DataManager::mInitialized = 0;
+map<string, DataManager::TStrIntPair>   DataManager::mValues;
+map<string, string>                     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 @@
 		}
 		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 @@
 
 	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 @@
 	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 7ac4bac..18decd0 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -61,6 +61,9 @@
 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 ee33731..d67e697 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 @@
 #include "rapidxml.hpp"
 #include "objects.hpp"
 
+#ifndef TW_NO_SCREEN_TIMEOUT
 extern blanktimer blankTimer;
+#endif
 
 void curtainClose(void);
 
@@ -339,7 +342,9 @@
 	}
 	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 5979c50..2b7d20e 100755
--- a/gui/devices/1024x600/res/ui.xml
+++ b/gui/devices/1024x600/res/ui.xml
@@ -2587,6 +2587,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2596,6 +2597,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2603,6 +2605,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml
index 86cfdda..b625174 100644
--- a/gui/devices/1024x768/res/ui.xml
+++ b/gui/devices/1024x768/res/ui.xml
@@ -2587,6 +2587,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2596,6 +2597,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2603,6 +2605,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/1080x1920/res/ui.xml b/gui/devices/1080x1920/res/ui.xml
index e23086a..29c8bc3 100644
--- a/gui/devices/1080x1920/res/ui.xml
+++ b/gui/devices/1080x1920/res/ui.xml
@@ -2598,6 +2598,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2607,6 +2608,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2614,6 +2616,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml
index 4a066a3..b86f991 100644
--- a/gui/devices/1280x800/res/ui.xml
+++ b/gui/devices/1280x800/res/ui.xml
@@ -2587,6 +2587,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2596,6 +2597,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2603,6 +2605,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml
index 458a723..157005f 100644
--- a/gui/devices/1920x1200/res/ui.xml
+++ b/gui/devices/1920x1200/res/ui.xml
@@ -2587,6 +2587,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2596,6 +2597,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2603,6 +2605,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/2560x1600/res/ui.xml b/gui/devices/2560x1600/res/ui.xml
index 6a77a4f..3d6b65f 100644
--- a/gui/devices/2560x1600/res/ui.xml
+++ b/gui/devices/2560x1600/res/ui.xml
@@ -2587,6 +2587,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2596,6 +2597,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2603,6 +2605,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml
index 041a135..0719a94 100644
--- a/gui/devices/320x480/res/ui.xml
+++ b/gui/devices/320x480/res/ui.xml
@@ -2585,6 +2585,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2594,6 +2595,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2601,6 +2603,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml
index 2b428b4..b7b527b 100644
--- a/gui/devices/480x800/res/ui.xml
+++ b/gui/devices/480x800/res/ui.xml
@@ -2585,6 +2585,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2594,6 +2595,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2601,6 +2603,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml
index f8d6da1..cb6577f 100644
--- a/gui/devices/480x854/res/ui.xml
+++ b/gui/devices/480x854/res/ui.xml
@@ -2584,6 +2584,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2593,6 +2594,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2600,6 +2602,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml
index 7448ddf..078f1ae 100644
--- a/gui/devices/540x960/res/ui.xml
+++ b/gui/devices/540x960/res/ui.xml
@@ -2585,6 +2585,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2594,6 +2595,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2601,6 +2603,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml
index 2319c55..d2896cc 100644
--- a/gui/devices/720x1280/res/ui.xml
+++ b/gui/devices/720x1280/res/ui.xml
@@ -2598,6 +2598,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2607,6 +2608,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2614,6 +2616,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml
index 692c736..ba7dba3 100755
--- a/gui/devices/800x1280/res/ui.xml
+++ b/gui/devices/800x1280/res/ui.xml
@@ -2586,6 +2586,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2595,6 +2596,7 @@
 				<placement x="%col1_x%" y="%row2_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2602,6 +2604,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="col1_x" y="%row4_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml
index 768f246..ba262bc 100755
--- a/gui/devices/800x480/res/ui.xml
+++ b/gui/devices/800x480/res/ui.xml
@@ -2595,6 +2595,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_false" />
 				<action function="set">tw_screen_timeout_secs=60</action>
@@ -2604,6 +2605,7 @@
 				<placement x="%slidervalue_x%" y="%row3_text_y%" />
 				<font resource="font" color="%text_color%" />
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<text>Enable screen timeout.</text>
 				<image resource="checkbox_true" />
 				<action function="set">tw_screen_timeout_secs=0</action>
@@ -2611,6 +2613,7 @@
 
 			<object type="slidervalue">
 				<condition var1="tw_screen_timeout_secs" op="!=" var2="0" />
+				<condition var1="tw_no_screen_timeout" op="!=" var2="1" />
 				<placement x="slidervalue_x" y="%row5_text_y%" w="%slidervalue_w%" />
 				<font resource="font" color="%text_color%" />
 				<colors line="%slidervalue_line_clr%" slider="%slidervalue_slider_clr%" />
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 821c7f5..6ee29d5 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -47,7 +47,9 @@
 #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 @@
 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 @@
 
 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 @@
 	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 @@
 				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 @@
 #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 @@
 				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 @@
 #endif
 				gettimeofday(&touchStart, NULL);
 				kb.KeyRepeat();
+#ifndef TW_NO_SCREEN_TIMEOUT
 				blankTimer.resetTimerAndUnblank();
+#endif
 			}
 		}
 		else if (ev.type == EV_ABS)
@@ -253,7 +271,9 @@
 					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 @@
 					dontwait = 1;
 					key_repeat = 0;
 					gettimeofday(&touchStart, NULL);
+#ifndef TW_NO_SCREEN_TIMEOUT
 					blankTimer.resetTimerAndUnblank();
+#endif
 				}
 				else
 				{
@@ -288,7 +310,9 @@
 						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 @@
 					touch_repeat = 0;
 					dontwait = 1;
 					gettimeofday(&touchStart, NULL);
+#ifndef TW_NO_SCREEN_TIMEOUT
 					blankTimer.resetTimerAndUnblank();
+#endif
 				}
 				else
 				{
@@ -317,7 +343,9 @@
 					touch_and_hold = 0;
 					touch_repeat = 0;
 					dontwait = 0;
+#ifndef TW_NO_SCREEN_TIMEOUT
 					blankTimer.resetTimerAndUnblank();
+#endif
 				}
 			}
 			else
@@ -328,7 +356,9 @@
 				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 9aea1b8..2bb70e1 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -41,10 +41,14 @@
 
 #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<std::string, PageSet*> PageManager::mPageSets;
 PageSet* PageManager::mCurrentSet;
@@ -919,9 +923,10 @@
 
 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 4020b75..b8a9380 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"