summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/Android.mk7
-rw-r--r--gui/action.cpp3
-rw-r--r--gui/blanktimer.cpp128
-rw-r--r--gui/blanktimer.hpp55
-rw-r--r--gui/gui.cpp1012
-rw-r--r--gui/gui.h26
-rw-r--r--twrp-functions.cpp49
-rw-r--r--twrp-functions.hpp104
-rw-r--r--twrpTar.cpp4
-rw-r--r--variables.h360
10 files changed, 1040 insertions, 708 deletions
diff --git a/gui/Android.mk b/gui/Android.mk
index 58d9c4ba0..9e11e5e2d 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -19,7 +19,9 @@ LOCAL_SRC_FILES := \
slider.cpp \
listbox.cpp \
keyboard.cpp \
- input.cpp
+ input.cpp \
+ blanktimer.cpp \
+ ../minuitwrp/graphics.c
ifneq ($(TWRP_CUSTOM_KEYBOARD),)
LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
@@ -46,6 +48,9 @@ endif
ifneq ($(TW_EXTERNAL_STORAGE_PATH),)
LOCAL_CFLAGS += -DTW_EXTERNAL_STORAGE_PATH=$(TW_EXTERNAL_STORAGE_PATH)
endif
+ifneq ($(TW_BRIGHTNESS_PATH),)
+ LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=$(TW_BRIGHTNESS_PATH)
+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 e56db2b76..f1dac1c9b 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -24,6 +24,7 @@
#include "../ui.h"
#include "../adb_install.h"
+#include "blanktimer.hpp"
extern "C" {
#include "../common.h"
@@ -44,6 +45,7 @@ int gui_start();
#include "objects.hpp"
extern RecoveryUI* ui;
+extern blanktimer blankTimer;
void curtainClose(void);
@@ -323,6 +325,7 @@ void GUIAction::operation_end(const int operation_status, const int simulate)
}
DataManager::SetValue("tw_operation_state", 1);
DataManager::SetValue(TW_ACTION_BUSY, 0);
+ blankTimer.resetTimerAndUnblank();
}
int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
new file mode 100644
index 000000000..f64bb5f45
--- /dev/null
+++ b/gui/blanktimer.cpp
@@ -0,0 +1,128 @@
+/*
+ Copyright 2012 bigbiff/Dees_Troy TeamWin
+ This file is part of TWRP/TeamWin Recovery Project.
+
+ TWRP is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ TWRP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TWRP. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using namespace std;
+#include "rapidxml.hpp"
+using namespace rapidxml;
+extern "C" {
+#include "../minzip/Zip.h"
+#include "../minuitwrp/minui.h"
+}
+#include <string>
+#include <vector>
+#include <map>
+#include "resources.hpp"
+#include <pthread.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+#include <pixelflinger/pixelflinger.h>
+#include <linux/kd.h>
+#include <linux/fb.h>
+#include <sstream>
+#include "pages.hpp"
+#include "blanktimer.hpp"
+extern "C" {
+#include "../common.h"
+#include "../recovery_ui.h"
+}
+#include "../twrp-functions.hpp"
+#include "../variables.h"
+
+blanktimer::blanktimer(void) {
+ blanked = 0;
+ sleepTimer = 60;
+ orig_brightness = getBrightness();
+}
+
+int blanktimer::setTimerThread(void) {
+ pthread_t thread;
+ ThreadPtr blankptr = &blanktimer::setClockTimer;
+ PThreadPtr p = *(PThreadPtr*)&blankptr;
+ pthread_create(&thread, NULL, p, this);
+ return 0;
+}
+
+void blanktimer::setBlank(int blank) {
+ pthread_mutex_lock(&blankmutex);
+ conblank = blank;
+ pthread_mutex_unlock(&blankmutex);
+}
+
+int blanktimer::getBlank(void) {
+ return conblank;
+}
+
+void blanktimer::setTimer(void) {
+ pthread_mutex_lock(&timermutex);
+ clock_gettime(CLOCK_MONOTONIC, &btimer);
+ pthread_mutex_unlock(&timermutex);
+}
+
+timespec blanktimer::getTimer(void) {
+ return btimer;
+}
+
+int blanktimer::setClockTimer(void) {
+ timespec curTime, diff;
+ while(1) {
+ usleep(1000);
+ clock_gettime(CLOCK_MONOTONIC, &curTime);
+ diff = TWFunc::timespec_diff(btimer, curTime);
+ if (diff.tv_sec > sleepTimer && conblank != 1)
+ setBlank(1);
+ if (conblank == 1 && blanked != 1) {
+ blanked = 1;
+ gr_fb_blank(conblank);
+ setBrightness(0);
+ PageManager::ChangeOverlay("lock");
+ }
+ }
+ return -1;
+}
+
+int blanktimer::getBrightness(void) {
+ string results;
+ string brightness_path = EXPAND(TW_BRIGHTNESS_PATH);
+ if ((TWFunc::read_file(brightness_path, results)) != 0)
+ return -1;
+ return atoi(results.c_str());
+
+}
+
+int blanktimer::setBrightness(int brightness) {
+ string brightness_path = EXPAND(TW_BRIGHTNESS_PATH);
+ string bstring;
+ char buff[100];
+ sprintf(buff, "%d", brightness);
+ bstring = buff;
+ if ((TWFunc::write_file(brightness_path, bstring)) != 0)
+ return -1;
+ return 0;
+}
+
+void blanktimer::resetTimerAndUnblank(void) {
+ setTimer();
+ if (blanked) {
+ setBrightness(orig_brightness);
+ blanked = 0;
+ setBlank(0);
+ gr_fb_blank(conblank);
+ gui_forceRender();
+ }
+}
diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp
new file mode 100644
index 000000000..74712bd75
--- /dev/null
+++ b/gui/blanktimer.hpp
@@ -0,0 +1,55 @@
+/*
+ Copyright 2012 bigbiff/Dees_Troy TeamWin
+ This file is part of TWRP/TeamWin Recovery Project.
+
+ TWRP is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ TWRP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TWRP. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __BLANKTIMER_HEADER_HPP
+#define __BLANKTIMER_HEADER_HPP
+
+#include <pthread.h>
+#include <sys/time.h>
+
+using namespace std;
+
+class blanktimer {
+ public:
+ blanktimer(void);
+ int setTimerThread(void);
+ void resetTimerAndUnblank(void);
+
+ private:
+ void setBlank(int blank);
+ int getBlank(void);
+ void setTimer(void);
+ timespec getTimer(void);
+ int getBrightness(void);
+ int setBrightness(int brightness);
+ int setBlankTimer(void);
+ int setClockTimer(void);
+ typedef int (blanktimer::*ThreadPtr)(void);
+ typedef void* (*PThreadPtr)(void*);
+ pthread_mutex_t blankmutex;
+ pthread_mutex_t timermutex;
+ int conblank;
+ timespec btimer;
+ unsigned long long sleepTimer;
+ int orig_brightness;
+ int blanked;
+};
+
+extern blanktimer blankTimer;
+
+#endif // __BLANKTIMER_HEADER_HPP
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 92eab2983..7fd474a35 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -33,8 +33,8 @@
#include <unistd.h>
#include <stdlib.h>
-
-extern "C" {
+extern "C"
+{
#include "../common.h"
#include "../roots.h"
#include "../minuitwrp/minui.h"
@@ -48,6 +48,8 @@ extern "C" {
#include "../data.hpp"
#include "../variables.h"
#include "../partitions.hpp"
+#include "../twrp-functions.hpp"
+#include "blanktimer.hpp"
const static int CURTAIN_FADE = 32;
@@ -59,609 +61,687 @@ static int gGuiInitialized = 0;
static int gGuiConsoleRunning = 0;
static int gGuiConsoleTerminate = 0;
static int gForceRender = 0;
+pthread_mutex_t gForceRendermutex;
static int gNoAnimation = 1;
static int gGuiInputRunning = 0;
+blanktimer blankTimer;
// Needed by pages.cpp too
int gGuiRunning = 0;
static int gRecorder = -1;
-extern "C" void gr_write_frame_to_file(int fd);
+extern "C" void gr_write_frame_to_file (int fd);
-void flip(void)
+void
+flip (void)
{
- if (gRecorder != -1)
- {
- timespec time;
- clock_gettime(CLOCK_MONOTONIC, &time);
- write(gRecorder, &time, sizeof(timespec));
- gr_write_frame_to_file(gRecorder);
- }
- gr_flip();
- return;
+ if (gRecorder != -1)
+ {
+ timespec time;
+ clock_gettime (CLOCK_MONOTONIC, &time);
+ write (gRecorder, &time, sizeof (timespec));
+ gr_write_frame_to_file (gRecorder);
+ }
+ gr_flip ();
+ return;
}
-void rapidxml::parse_error_handler(const char *what, void *where)
+void
+rapidxml::parse_error_handler (const char *what, void *where)
{
- fprintf(stderr, "Parser error: %s\n", what);
- fprintf(stderr, " Start of string: %s\n", (char*) where);
- abort();
+ fprintf (stderr, "Parser error: %s\n", what);
+ fprintf (stderr, " Start of string: %s\n", (char *) where);
+ abort ();
}
-static void curtainSet()
+static void
+curtainSet ()
{
- gr_color(0, 0, 0, 255);
- gr_fill(0, 0, gr_fb_width(), gr_fb_height());
- gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
- gr_flip();
- return;
+ gr_color (0, 0, 0, 255);
+ gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
+ gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain), gr_get_height (gCurtain),
+ 0, 0);
+ gr_flip ();
+ return;
}
-static void curtainRaise(gr_surface surface)
+static void
+curtainRaise (gr_surface surface)
{
- int sy = 0;
- int h = gr_get_height(gCurtain) - 1;
- int w = gr_get_width(gCurtain);
- int fy = 1;
-
- int msw = gr_get_width(surface);
- int msh = gr_get_height(surface);
- int CURTAIN_RATE = msh / 30;
-
- if (gNoAnimation == 0)
- {
- for (; h > 0; h -= CURTAIN_RATE, sy += CURTAIN_RATE, fy += CURTAIN_RATE)
- {
- gr_blit(surface, 0, 0, msw, msh, 0, 0);
- gr_blit(gCurtain, 0, sy, w, h, 0, 0);
- gr_flip();
- }
- }
- gr_blit(surface, 0, 0, msw, msh, 0, 0);
- flip();
- return;
+ int sy = 0;
+ int h = gr_get_height (gCurtain) - 1;
+ int w = gr_get_width (gCurtain);
+ int fy = 1;
+
+ int msw = gr_get_width (surface);
+ int msh = gr_get_height (surface);
+ int CURTAIN_RATE = msh / 30;
+
+ if (gNoAnimation == 0)
+ {
+ for (; h > 0; h -= CURTAIN_RATE, sy += CURTAIN_RATE, fy += CURTAIN_RATE)
+ {
+ gr_blit (surface, 0, 0, msw, msh, 0, 0);
+ gr_blit (gCurtain, 0, sy, w, h, 0, 0);
+ gr_flip ();
+ }
+ }
+ gr_blit (surface, 0, 0, msw, msh, 0, 0);
+ flip ();
+ return;
}
-void curtainClose()
+void
+curtainClose ()
{
#if 0
- int w = gr_get_width(gCurtain);
- int h = 1;
- int sy = gr_get_height(gCurtain) - 1;
- int fbh = gr_fb_height();
- int CURTAIN_RATE = fbh / 30;
-
- if (gNoAnimation == 0)
- {
- for (; h < fbh; h += CURTAIN_RATE, sy -= CURTAIN_RATE)
- {
- gr_blit(gCurtain, 0, sy, w, h, 0, 0);
- gr_flip();
- }
- gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
- gr_flip();
-
- if (gRecorder != -1)
- close(gRecorder);
-
- int fade;
- for (fade = 16; fade < 255; fade += CURTAIN_FADE)
- {
- gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
- gr_color(0, 0, 0, fade);
- gr_fill(0, 0, gr_fb_width(), gr_fb_height());
- gr_flip();
- }
- gr_color(0, 0, 0, 255);
- gr_fill(0, 0, gr_fb_width(), gr_fb_height());
- gr_flip();
- }
+ int w = gr_get_width (gCurtain);
+ int h = 1;
+ int sy = gr_get_height (gCurtain) - 1;
+ int fbh = gr_fb_height ();
+ int CURTAIN_RATE = fbh / 30;
+
+ if (gNoAnimation == 0)
+ {
+ for (; h < fbh; h += CURTAIN_RATE, sy -= CURTAIN_RATE)
+ {
+ gr_blit (gCurtain, 0, sy, w, h, 0, 0);
+ gr_flip ();
+ }
+ gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain),
+ gr_get_height (gCurtain), 0, 0);
+ gr_flip ();
+
+ if (gRecorder != -1)
+ close (gRecorder);
+
+ int fade;
+ for (fade = 16; fade < 255; fade += CURTAIN_FADE)
+ {
+ gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain),
+ gr_get_height (gCurtain), 0, 0);
+ gr_color (0, 0, 0, fade);
+ gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
+ gr_flip ();
+ }
+ gr_color (0, 0, 0, 255);
+ gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
+ gr_flip ();
+ }
#else
- gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
- gr_flip();
+ gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain), gr_get_height (gCurtain),
+ 0, 0);
+ gr_flip ();
#endif
- return;
+ return;
}
-timespec timespec_diff(timespec& start, timespec& end)
+static void *
+input_thread (void *cookie)
{
- timespec temp;
- if ((end.tv_nsec-start.tv_nsec)<0) {
- temp.tv_sec = end.tv_sec-start.tv_sec-1;
- temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
- } else {
- temp.tv_sec = end.tv_sec-start.tv_sec;
- temp.tv_nsec = end.tv_nsec-start.tv_nsec;
- }
- return temp;
-}
+ int drag = 0;
+ static int touch_and_hold = 0, dontwait = 0, touch_repeat = 0, x = 0, y =
+ 0, lshift = 0, rshift = 0, key_repeat = 0;
+ static struct timeval touchStart;
+ HardwareKeyboard kb;
-static void *input_thread(void *cookie)
-{
- int drag = 0;
- static int touch_and_hold = 0, dontwait = 0, touch_repeat = 0, x = 0, y = 0, lshift = 0, rshift = 0, key_repeat = 0;
- static struct timeval touchStart;
- HardwareKeyboard kb;
+ //start screen timeout threads
+ blankTimer.setTimerThread();
- for (;;) {
+ for (;;)
+ {
- // wait for the next event
- struct input_event ev;
- int state = 0, ret = 0;
+ // wait for the next event
+ struct input_event ev;
+ int state = 0, ret = 0;
- ret = ev_get(&ev, dontwait);
+ ret = ev_get (&ev, dontwait);
- if (ret < 0) {
- struct timeval curTime;
- gettimeofday(&curTime, NULL);
- long mtime, seconds, useconds;
+ if (ret < 0)
+ {
+ struct timeval curTime;
+ gettimeofday (&curTime, NULL);
+ long mtime, seconds, useconds;
- seconds = curTime.tv_sec - touchStart.tv_sec;
- useconds = curTime.tv_usec - touchStart.tv_usec;
+ seconds = curTime.tv_sec - touchStart.tv_sec;
+ useconds = curTime.tv_usec - touchStart.tv_usec;
- mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
- if (touch_and_hold && mtime > 500) {
- touch_and_hold = 0;
- touch_repeat = 1;
- gettimeofday(&touchStart, NULL);
+ mtime = ((seconds) * 1000 + useconds / 1000.0) + 0.5;
+ if (touch_and_hold && mtime > 500)
+ {
+ touch_and_hold = 0;
+ touch_repeat = 1;
+ gettimeofday (&touchStart, NULL);
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_HOLD: %d,%d\n", x, y);
+ LOGE ("TOUCH_HOLD: %d,%d\n", x, y);
#endif
- PageManager::NotifyTouch(TOUCH_HOLD, x, y);
- } else if (touch_repeat && mtime > 100) {
+ PageManager::NotifyTouch (TOUCH_HOLD, x, y);
+ blankTimer.resetTimerAndUnblank();
+ }
+ else if (touch_repeat && mtime > 100)
+ {
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_REPEAT: %d,%d\n", x, y);
+ LOGE ("TOUCH_REPEAT: %d,%d\n", x, y);
#endif
- gettimeofday(&touchStart, NULL);
- PageManager::NotifyTouch(TOUCH_REPEAT, x, y);
- } else if (key_repeat == 1 && mtime > 500) {
+ gettimeofday (&touchStart, NULL);
+ PageManager::NotifyTouch (TOUCH_REPEAT, x, y);
+ blankTimer.resetTimerAndUnblank();
+ }
+ else if (key_repeat == 1 && mtime > 500)
+ {
#ifdef _EVENT_LOGGING
- LOGE("KEY_HOLD: %d,%d\n", x, y);
+ LOGE ("KEY_HOLD: %d,%d\n", x, y);
#endif
- gettimeofday(&touchStart, NULL);
- key_repeat = 2;
- kb.KeyRepeat();
- } else if (key_repeat == 2 && mtime > 100) {
+ gettimeofday (&touchStart, NULL);
+ key_repeat = 2;
+ kb.KeyRepeat ();
+ blankTimer.resetTimerAndUnblank();
+ }
+ else if (key_repeat == 2 && mtime > 100)
+ {
#ifdef _EVENT_LOGGING
- LOGE("KEY_REPEAT: %d,%d\n", x, y);
+ LOGE ("KEY_REPEAT: %d,%d\n", x, y);
#endif
- gettimeofday(&touchStart, NULL);
- kb.KeyRepeat();
+ gettimeofday (&touchStart, NULL);
+ kb.KeyRepeat ();
+ blankTimer.resetTimerAndUnblank();
}
- } else if (ev.type == EV_ABS) {
+ }
+ else if (ev.type == EV_ABS)
+ {
- x = ev.value >> 16;
- y = ev.value & 0xFFFF;
+ x = ev.value >> 16;
+ y = ev.value & 0xFFFF;
- if (ev.code == 0)
- {
- if (state == 0)
- {
+ if (ev.code == 0)
+ {
+ if (state == 0)
+ {
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_RELEASE: %d,%d\n", x, y);
+ LOGE ("TOUCH_RELEASE: %d,%d\n", x, y);
#endif
- PageManager::NotifyTouch(TOUCH_RELEASE, x, y);
- touch_and_hold = 0;
- touch_repeat = 0;
- if (!key_repeat)
- dontwait = 0;
- }
- state = 0;
- drag = 0;
- }
- else
- {
- if (!drag)
- {
+ PageManager::NotifyTouch (TOUCH_RELEASE, x, y);
+ blankTimer.resetTimerAndUnblank();
+ touch_and_hold = 0;
+ touch_repeat = 0;
+ if (!key_repeat)
+ dontwait = 0;
+ }
+ state = 0;
+ drag = 0;
+ }
+ else
+ {
+ if (!drag)
+ {
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_START: %d,%d\n", x, y);
+ LOGE ("TOUCH_START: %d,%d\n", x, y);
#endif
- if (PageManager::NotifyTouch(TOUCH_START, x, y) > 0)
- state = 1;
- drag = 1;
- touch_and_hold = 1;
- dontwait = 1;
- key_repeat = 0;
- gettimeofday(&touchStart, NULL);
- }
- else
- {
- if (state == 0)
- {
+ if (PageManager::NotifyTouch (TOUCH_START, x, y) > 0)
+ state = 1;
+ drag = 1;
+ touch_and_hold = 1;
+ dontwait = 1;
+ key_repeat = 0;
+ gettimeofday (&touchStart, NULL);
+ blankTimer.resetTimerAndUnblank();
+ }
+ else
+ {
+ if (state == 0)
+ {
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_DRAG: %d,%d\n", x, y);
+ LOGE ("TOUCH_DRAG: %d,%d\n", x, y);
#endif
- if (PageManager::NotifyTouch(TOUCH_DRAG, x, y) > 0)
- state = 1;
- key_repeat = 0;
- }
- }
- }
- }
- else if (ev.type == EV_KEY)
- {
- // Handle key-press here
+ if (PageManager::NotifyTouch (TOUCH_DRAG, x, y) > 0)
+ state = 1;
+ key_repeat = 0;
+ blankTimer.resetTimerAndUnblank();
+ }
+ }
+ }
+ }
+ else if (ev.type == EV_KEY)
+ {
+ // Handle key-press here
#ifdef _EVENT_LOGGING
- LOGE("TOUCH_KEY: %d\n", ev.code);
+ LOGE ("TOUCH_KEY: %d\n", ev.code);
#endif
- if (ev.value != 0) {
- // This is a key press
- if (kb.KeyDown(ev.code)) {
- key_repeat = 1;
- touch_and_hold = 0;
- touch_repeat = 0;
- dontwait = 1;
- gettimeofday(&touchStart, NULL);
- } else {
- key_repeat = 0;
- touch_and_hold = 0;
- touch_repeat = 0;
- dontwait = 0;
+ if (ev.value != 0)
+ {
+ // This is a key press
+ if (kb.KeyDown (ev.code))
+ {
+ key_repeat = 1;
+ touch_and_hold = 0;
+ touch_repeat = 0;
+ dontwait = 1;
+ gettimeofday (&touchStart, NULL);
+ blankTimer.resetTimerAndUnblank();
+ }
+ else
+ {
+ key_repeat = 0;
+ touch_and_hold = 0;
+ touch_repeat = 0;
+ dontwait = 0;
+ blankTimer.resetTimerAndUnblank();
}
- } else {
- // This is a key release
- kb.KeyUp(ev.code);
- key_repeat = 0;
- touch_and_hold = 0;
- touch_repeat = 0;
- dontwait = 0;
}
- }
- }
- return NULL;
+ else
+ {
+ // This is a key release
+ kb.KeyUp (ev.code);
+ key_repeat = 0;
+ touch_and_hold = 0;
+ touch_repeat = 0;
+ dontwait = 0;
+ blankTimer.resetTimerAndUnblank();
+ }
+ }
+ }
+ return NULL;
}
// This special function will return immediately the first time, but then
// always returns 1/30th of a second (or immediately if called later) from
// the last time it was called
-static void loopTimer(void)
+static void
+loopTimer (void)
{
- static timespec lastCall;
- static int initialized = 0;
-
- if (!initialized)
- {
- clock_gettime(CLOCK_MONOTONIC, &lastCall);
- initialized = 1;
- return;
- }
-
- do
- {
- timespec curTime;
- clock_gettime(CLOCK_MONOTONIC, &curTime);
-
- timespec diff = timespec_diff(lastCall, curTime);
-
- // This is really 30 times per second
- if (diff.tv_sec || diff.tv_nsec > 33333333)
- {
- lastCall = curTime;
- return;
- }
-
- // We need to sleep some period time microseconds
- unsigned int sleepTime = 33333 - (diff.tv_nsec / 1000);
- usleep(sleepTime);
- } while(1);
- return;
+ static timespec lastCall;
+ static int initialized = 0;
+
+ if (!initialized)
+ {
+ clock_gettime (CLOCK_MONOTONIC, &lastCall);
+ initialized = 1;
+ return;
+ }
+
+ do
+ {
+ timespec curTime;
+ clock_gettime (CLOCK_MONOTONIC, &curTime);
+
+ timespec diff = TWFunc::timespec_diff (lastCall, curTime);
+
+ // This is really 30 times per second
+ if (diff.tv_sec || diff.tv_nsec > 33333333)
+ {
+ lastCall = curTime;
+ return;
+ }
+
+ // We need to sleep some period time microseconds
+ unsigned int sleepTime = 33333 - (diff.tv_nsec / 1000);
+ usleep (sleepTime);
+ }
+ while (1);
+ return;
}
-static int runPages(void)
+static int
+runPages (void)
{
- // 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();
- }
- }
-
- gGuiRunning = 0;
- return 0;
+ // 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
+ {
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 0;
+ pthread_mutex_unlock(&gForceRendermutex);
+ PageManager::Render ();
+ flip ();
+ }
+ }
+
+ gGuiRunning = 0;
+ return 0;
}
-static int runPage(const char* page_name)
+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;
+ 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
+ {
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 0;
+ pthread_mutex_unlock(&gForceRendermutex);
+ PageManager::Render ();
+ flip ();
}
- }
+ if (DataManager::GetIntValue ("tw_page_done") != 0)
+ {
+ gui_changePage ("main");
+ break;
+ }
+ }
- gGuiRunning = 0;
- return 0;
+ gGuiRunning = 0;
+ return 0;
}
-int gui_forceRender(void)
+int
+gui_forceRender (void)
{
- gForceRender = 1;
- return 0;
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 1;
+ pthread_mutex_unlock(&gForceRendermutex);
+ return 0;
}
-int gui_changePage(std::string newPage)
+int
+gui_changePage (std::string newPage)
{
- LOGI("Set page: '%s'\n", newPage.c_str());
- PageManager::ChangePage(newPage);
- gForceRender = 1;
- return 0;
+ LOGI ("Set page: '%s'\n", newPage.c_str ());
+ PageManager::ChangePage (newPage);
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 1;
+ pthread_mutex_unlock(&gForceRendermutex);
+ return 0;
}
-int gui_changeOverlay(std::string overlay)
+int
+gui_changeOverlay (std::string overlay)
{
- PageManager::ChangeOverlay(overlay);
- gForceRender = 1;
- return 0;
+ PageManager::ChangeOverlay (overlay);
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 1;
+ pthread_mutex_unlock(&gForceRendermutex);
+ return 0;
}
-int gui_changePackage(std::string newPackage)
+int
+gui_changePackage (std::string newPackage)
{
- PageManager::SelectPackage(newPackage);
- gForceRender = 1;
- return 0;
+ PageManager::SelectPackage (newPackage);
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 1;
+ pthread_mutex_unlock(&gForceRendermutex);
+ return 0;
}
-std::string gui_parse_text(string inText)
+std::string gui_parse_text (string inText)
{
- // Copied from std::string GUIText::parseText(void)
- // This function parses text for DataManager values encompassed by %value% in the XML
- static int counter = 0;
- std::string str = inText;
- size_t pos = 0;
- size_t next = 0, end = 0;
-
- while (1)
- {
- next = str.find('%', pos);
- if (next == std::string::npos) return str;
- end = str.find('%', next + 1);
- if (end == std::string::npos) return str;
-
- // We have a block of data
- std::string var = str.substr(next + 1, (end - next) - 1);
- str.erase(next, (end - next) + 1);
-
- if (next + 1 == end)
- {
- str.insert(next, 1, '%');
- }
- else
- {
- std::string value;
- if (DataManager::GetValue(var, value) == 0)
- str.insert(next, value);
- }
-
- pos = next + 1;
- }
+ // Copied from std::string GUIText::parseText(void)
+ // This function parses text for DataManager values encompassed by %value% in the XML
+ static int counter = 0;
+ std::string str = inText;
+ size_t pos = 0;
+ size_t next = 0, end = 0;
+
+ while (1)
+ {
+ next = str.find ('%', pos);
+ if (next == std::string::npos)
+ return str;
+ end = str.find ('%', next + 1);
+ if (end == std::string::npos)
+ return str;
+
+ // We have a block of data
+ std::string var = str.substr (next + 1, (end - next) - 1);
+ str.erase (next, (end - next) + 1);
+
+ if (next + 1 == end)
+ {
+ str.insert (next, 1, '%');
+ }
+ else
+ {
+ std::string value;
+ if (DataManager::GetValue (var, value) == 0)
+ str.insert (next, value);
+ }
+
+ pos = next + 1;
+ }
}
-extern "C" int gui_init()
+extern "C" int
+gui_init ()
{
- int fd;
+ int fd;
- gr_init();
+ gr_init ();
- if (res_create_surface("/res/images/curtain.jpg", &gCurtain))
+ if (res_create_surface ("/res/images/curtain.jpg", &gCurtain))
{
- printf("Unable to locate '/res/images/curtain.jpg'\nDid you set a DEVICE_RESOLUTION in your config files?\n");
- return -1;
+ printf
+ ("Unable to locate '/res/images/curtain.jpg'\nDid you set a DEVICE_RESOLUTION in your config files?\n");
+ return -1;
}
- curtainSet();
+ curtainSet ();
- ev_init();
- return 0;
+ ev_init ();
+ return 0;
}
-extern "C" int gui_loadResources()
+extern "C" int
+gui_loadResources ()
{
// unlink("/sdcard/video.last");
// rename("/sdcard/video.bin", "/sdcard/video.last");
// gRecorder = open("/sdcard/video.bin", O_CREAT | O_WRONLY);
- int check = 0;
- DataManager::GetValue(TW_IS_ENCRYPTED, check);
- if (check) {
- if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "decrypt"))
+ int check = 0;
+ DataManager::GetValue (TW_IS_ENCRYPTED, check);
+ if (check)
+ {
+ if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "decrypt"))
{
- LOGE("Failed to load base packages.\n");
- goto error;
- } else
- check = 1;
+ LOGE ("Failed to load base packages.\n");
+ goto error;
+ }
+ else
+ check = 1;
}
- if (check == 0 && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main")) {
- std::string theme_path;
-
- theme_path = DataManager::GetSettingsStoragePath();
- if (!PartitionManager.Mount_Settings_Storage(false)) {
- int retry_count = 5;
- while (retry_count > 0 && !PartitionManager.Mount_Settings_Storage(false)) {
- usleep(500000);
- retry_count--;
+ if (check == 0
+ && PageManager::LoadPackage ("TWRP", "/script/ui.xml", "main"))
+ {
+ std::string theme_path;
+
+ theme_path = DataManager::GetSettingsStoragePath ();
+ if (!PartitionManager.Mount_Settings_Storage (false))
+ {
+ int retry_count = 5;
+ while (retry_count > 0
+ && !PartitionManager.Mount_Settings_Storage (false))
+ {
+ usleep (500000);
+ retry_count--;
}
- if (!PartitionManager.Mount_Settings_Storage(false)) {
- LOGE("Unable to mount %s during GUI startup.\n", theme_path.c_str());
- check = 1;
+ if (!PartitionManager.Mount_Settings_Storage (false))
+ {
+ LOGE ("Unable to mount %s during GUI startup.\n",
+ theme_path.c_str ());
+ check = 1;
}
}
- theme_path += "/TWRP/theme/ui.zip";
- if (check || PageManager::LoadPackage("TWRP", theme_path, "main"))
+ theme_path += "/TWRP/theme/ui.zip";
+ if (check || PageManager::LoadPackage ("TWRP", theme_path, "main"))
{
- if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
+ if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "main"))
{
- LOGE("Failed to load base packages.\n");
- goto error;
+ LOGE ("Failed to load base packages.\n");
+ goto error;
}
}
}
- // Set the default package
- PageManager::SelectPackage("TWRP");
+ // Set the default package
+ PageManager::SelectPackage ("TWRP");
- gGuiInitialized = 1;
- return 0;
+ gGuiInitialized = 1;
+ return 0;
error:
- LOGE("An internal error has occurred.\n");
- gGuiInitialized = 0;
- return -1;
+ LOGE ("An internal error has occurred.\n");
+ gGuiInitialized = 0;
+ return -1;
}
-extern "C" int gui_start()
+extern "C" int
+gui_start ()
{
- if (!gGuiInitialized) return -1;
+ if (!gGuiInitialized)
+ return -1;
- gGuiConsoleTerminate = 1;
- while (gGuiConsoleRunning) loopTimer();
+ gGuiConsoleTerminate = 1;
+ while (gGuiConsoleRunning)
+ loopTimer ();
- // Set the default package
- PageManager::SelectPackage("TWRP");
+ // 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;
+ if (!gGuiInputRunning)
+ {
+ // Start by spinning off an input handler.
+ pthread_t t;
+ pthread_create (&t, NULL, input_thread, NULL);
+ gGuiInputRunning = 1;
}
- return runPages();
+ return runPages ();
}
-extern "C" int gui_startPage(const char* page_name)
+extern "C" int
+gui_startPage (const char *page_name)
{
- if (!gGuiInitialized) return -1;
+ if (!gGuiInitialized)
+ return -1;
- gGuiConsoleTerminate = 1;
- while (gGuiConsoleRunning) loopTimer();
+ gGuiConsoleTerminate = 1;
+ while (gGuiConsoleRunning)
+ loopTimer ();
- // Set the default package
- PageManager::SelectPackage("TWRP");
+ // 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;
+ if (!gGuiInputRunning)
+ {
+ // Start by spinning off an input handler.
+ pthread_t t;
+ pthread_create (&t, NULL, input_thread, NULL);
+ gGuiInputRunning = 1;
}
- DataManager::SetValue("tw_page_done", 0);
- return runPage(page_name);
+ DataManager::SetValue ("tw_page_done", 0);
+ return runPage (page_name);
}
-static void *console_thread(void *cookie)
+static void *
+console_thread (void *cookie)
{
- PageManager::SwitchToConsole();
-
- while (!gGuiConsoleTerminate)
- {
- loopTimer();
-
- if (!gForceRender)
- {
- int ret;
-
- ret = PageManager::Update();
- if (ret > 1)
- PageManager::Render();
-
- if (ret > 0)
- flip();
-
- if (ret < 0)
- LOGE("An update request has failed.\n");
- }
- else
- {
- gForceRender = 0;
- PageManager::Render();
- flip();
- }
- }
- gGuiConsoleRunning = 0;
- return NULL;
+ PageManager::SwitchToConsole ();
+
+ while (!gGuiConsoleTerminate)
+ {
+ loopTimer ();
+
+ if (!gForceRender)
+ {
+ int ret;
+
+ ret = PageManager::Update ();
+ if (ret > 1)
+ PageManager::Render ();
+
+ if (ret > 0)
+ flip ();
+
+ if (ret < 0)
+ LOGE ("An update request has failed.\n");
+ }
+ else
+ {
+ pthread_mutex_lock(&gForceRendermutex);
+ gForceRender = 0;
+ pthread_mutex_unlock(&gForceRendermutex);
+ PageManager::Render ();
+ flip ();
+ }
+ }
+ gGuiConsoleRunning = 0;
+ return NULL;
}
-extern "C" int gui_console_only()
+extern "C" int
+gui_console_only ()
{
- if (!gGuiInitialized) return -1;
+ if (!gGuiInitialized)
+ return -1;
- gGuiConsoleTerminate = 0;
- gGuiConsoleRunning = 1;
+ gGuiConsoleTerminate = 0;
+ gGuiConsoleRunning = 1;
- // Start by spinning off an input handler.
- pthread_t t;
- pthread_create(&t, NULL, console_thread, NULL);
+ // Start by spinning off an input handler.
+ pthread_t t;
+ pthread_create (&t, NULL, console_thread, NULL);
- return 0;
+ return 0;
}
diff --git a/gui/gui.h b/gui/gui.h
index ee3cc272a..c6af2e4d1 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -1,13 +1,13 @@
-#ifndef _GUI_HEADER
-#define _GUI_HEADER
-
-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, ...);
-
-#endif // _GUI_HEADER
-
+#ifndef _GUI_HEADER
+#define _GUI_HEADER
+
+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, ...);
+
+#endif // _GUI_HEADER
+
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index fa2110aa0..85ce7274a 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -12,6 +12,7 @@
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <sys/vfs.h>
+#include "cutils/android_reboot.h"
#include <iostream>
#include <fstream>
#include "twrp-functions.hpp"
@@ -374,6 +375,7 @@ int TWFunc::tw_reboot(RebootCommand command)
return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "bootloader");
case rb_poweroff:
check_and_run_script("/sbin/poweroff.sh", "power off");
+ android_reboot(ANDROID_RB_POWEROFF, 0, 0);
return reboot(RB_POWER_OFF);
case rb_download:
check_and_run_script("/sbin/rebootdownload.sh", "reboot download");
@@ -449,6 +451,8 @@ int TWFunc::copy_file(string src, string dst, int mode) {
dstfile << srcfile.rdbuf();
srcfile.close();
dstfile.close();
+ if (chmod(dst.c_str(), mode) != 0)
+ return -1;
return 0;
}
@@ -472,3 +476,48 @@ unsigned int TWFunc::Get_D_Type_From_Stat(string Path) {
return DT_SOCK;
return DT_UNKNOWN;
}
+
+int TWFunc::read_file(string fn, string& results) {
+ ifstream file;
+ file.open(fn.c_str(), ios::in);
+ if (file.is_open()) {
+ file >> results;
+ file.close();
+ return 0;
+ }
+ LOGI("Cannot find file %s\n", fn.c_str());
+ return -1;
+}
+
+int TWFunc::write_file(string fn, string& line) {
+ FILE *file;
+ file = fopen(fn.c_str(), "w");
+ if (file != NULL) {
+ fwrite(line.c_str(), line.size(), 1, file);
+ fclose(file);
+ return 0;
+ }
+ LOGI("Cannot find file %s\n", fn.c_str());
+ return -1;
+}
+
+timespec TWFunc::timespec_diff(timespec& start, timespec& end)
+{
+ timespec temp;
+ if ((end.tv_nsec-start.tv_nsec)<0) {
+ temp.tv_sec = end.tv_sec-start.tv_sec-1;
+ temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
+ } else {
+ temp.tv_sec = end.tv_sec-start.tv_sec;
+ temp.tv_nsec = end.tv_nsec-start.tv_nsec;
+ }
+ return temp;
+}
+
+ int TWFunc::drop_caches(void) {
+ string file = "/proc/sys/vm/drop_caches";
+ string value = "3";
+ if (write_file(file, value) != 0)
+ return -1;
+ return 0;
+}
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index fc2d64787..d7dea3f2a 100644
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -1,50 +1,54 @@
-#ifndef _TWRPFUNCTIONS_HPP
-#define _TWRPFUNCTIONS_HPP
-
-#include <string>
-
-using namespace std;
-
-typedef enum
-{
- rb_current = 0,
- rb_system,
- rb_recovery,
- rb_poweroff,
- rb_bootloader, // May also be fastboot
- rb_download,
-} RebootCommand;
-
-// Partition class
-class TWFunc
-{
-public:
- static int Check_MD5(string File);
- static string Get_Root_Path(string Path); // Trims any trailing folders or filenames from the path, also adds a leading / if not present
- static string Get_Path(string Path); // Trims everything after the last / in the string
- static string Get_Filename(string Path); // Trims the path off of a filename
-
- static void install_htc_dumlock(void); // Installs HTC Dumlock
- static void htc_dumlock_restore_original_boot(void); // Restores the backup of boot from HTC Dumlock
- static void htc_dumlock_reflash_recovery_to_boot(void); // Reflashes the current recovery to boot
- static int Recursive_Mkdir(string Path); // Recursively makes the entire path
- static unsigned long long Get_Folder_Size(const string& Path, bool Display_Error); // Gets the size of a folder and all of its subfolders using dirent and stat
- static bool Path_Exists(string Path); // Returns true if the path exists
- static void GUI_Operation_Text(string Read_Value, string Default_Text); // Updates text for display in the GUI, e.g. Backing up %partition name%
- static void GUI_Operation_Text(string Read_Value, string Partition_Name, string Default_Text); // Same as above but includes partition name
- static unsigned long Get_File_Size(string Path); // Returns the size of a file
- static void twfinish_recovery(const char *send_intent); // Writes the log to last_log
- static int tw_reboot(RebootCommand command); // Prepares the device for rebooting
- static void check_and_run_script(const char* script_file, const char* display_name); // checks for the existence of a script, chmods it to 755, then runs it
- static int Exec_Cmd(string cmd, string &result); //execute a command and return the result as a string by reference
- static int removeDir(const string path, bool removeParent); //recursively remove a directory
- static int copy_file(string src, string dst, int mode); //copy file from src to dst with mode permissions
- static unsigned int Get_D_Type_From_Stat(string Path); // Returns a dirent dt_type value using stat instead of dirent
-
-private:
- static void check_and_fclose(FILE *fp, const char *name);
- static void copy_log_file(const char* source, const char* destination, int append);
-
-};
-
-#endif // _TWRPFUNCTIONS_HPP
+#ifndef _TWRPFUNCTIONS_HPP
+#define _TWRPFUNCTIONS_HPP
+
+#include <string>
+
+using namespace std;
+
+typedef enum
+{
+ rb_current = 0,
+ rb_system,
+ rb_recovery,
+ rb_poweroff,
+ rb_bootloader, // May also be fastboot
+ rb_download,
+} RebootCommand;
+
+// Partition class
+class TWFunc
+{
+public:
+ static int Check_MD5(string File);
+ static string Get_Root_Path(string Path); // Trims any trailing folders or filenames from the path, also adds a leading / if not present
+ static string Get_Path(string Path); // Trims everything after the last / in the string
+ static string Get_Filename(string Path); // Trims the path off of a filename
+
+ static void install_htc_dumlock(void); // Installs HTC Dumlock
+ static void htc_dumlock_restore_original_boot(void); // Restores the backup of boot from HTC Dumlock
+ static void htc_dumlock_reflash_recovery_to_boot(void); // Reflashes the current recovery to boot
+ static int Recursive_Mkdir(string Path); // Recursively makes the entire path
+ static unsigned long long Get_Folder_Size(const string& Path, bool Display_Error); // Gets the size of a folder and all of its subfolders using dirent and stat
+ static bool Path_Exists(string Path); // Returns true if the path exists
+ static void GUI_Operation_Text(string Read_Value, string Default_Text); // Updates text for display in the GUI, e.g. Backing up %partition name%
+ static void GUI_Operation_Text(string Read_Value, string Partition_Name, string Default_Text); // Same as above but includes partition name
+ static unsigned long Get_File_Size(string Path); // Returns the size of a file
+ static void twfinish_recovery(const char *send_intent); // Writes the log to last_log
+ static int tw_reboot(RebootCommand command); // Prepares the device for rebooting
+ static void check_and_run_script(const char* script_file, const char* display_name); // checks for the existence of a script, chmods it to 755, then runs it
+ static int Exec_Cmd(string cmd, string &result); //execute a command and return the result as a string by reference
+ static int removeDir(const string path, bool removeParent); //recursively remove a directory
+ static int copy_file(string src, string dst, int mode); //copy file from src to dst with mode permissions
+ static unsigned int Get_D_Type_From_Stat(string Path); // Returns a dirent dt_type value using stat instead of dirent
+ static timespec timespec_diff(timespec& start, timespec& end); // Return a diff for 2 times
+ static int read_file(string fn, string& results); //read from file
+ static int write_file(string fn, string& line); //write from file
+ static int drop_caches(void); //drop linux cache memory
+
+private:
+ static void check_and_fclose(FILE *fp, const char *name);
+ static void copy_log_file(const char* source, const char* destination, int append);
+
+};
+
+#endif // _TWRPFUNCTIONS_HPP
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 263684995..43448672c 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -57,6 +57,7 @@ int twrpTar::createTarGZThread() {
if(pthread_join(thread, NULL)) {
return -1;
}
+ TWFunc::drop_caches();
return 0;
}
@@ -68,6 +69,7 @@ int twrpTar::createTarThread() {
if(pthread_join(thread, NULL)) {
return -1;
}
+ TWFunc::drop_caches();
return 0;
}
@@ -79,6 +81,7 @@ int twrpTar::extractTarThread() {
if(pthread_join(thread, NULL)) {
return -1;
}
+ TWFunc::drop_caches();
return 0;
}
@@ -90,6 +93,7 @@ int twrpTar::splitArchiveThread() {
if(pthread_join(thread, NULL)) {
return -1;
}
+ TWFunc::drop_caches();
return 0;
}
diff --git a/variables.h b/variables.h
index d43be8165..7f2ab0000 100644
--- a/variables.h
+++ b/variables.h
@@ -1,178 +1,182 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _VARIABLES_HEADER_
-#define _VARIABLES_HEADER_
-
-#define TW_VERSION_STR "2.4.1.0"
-
-#define TW_USE_COMPRESSION_VAR "tw_use_compression"
-#define TW_IGNORE_IMAGE_SIZE "tw_ignore_image_size"
-#define TW_FILENAME "tw_filename"
-#define TW_ZIP_INDEX "tw_zip_index"
-#define TW_ZIP_QUEUE_COUNT "tw_zip_queue_count"
-
-#define MAX_BACKUP_NAME_LEN 64
-#define TW_BACKUP_TEXT "tw_backup_text"
-#define TW_BACKUP_NAME "tw_backup_name"
-#define TW_BACKUP_SYSTEM_VAR "tw_backup_system"
-#define TW_BACKUP_DATA_VAR "tw_backup_data"
-#define TW_BACKUP_BOOT_VAR "tw_backup_boot"
-#define TW_BACKUP_RECOVERY_VAR "tw_backup_recovery"
-#define TW_BACKUP_CACHE_VAR "tw_backup_cache"
-#define TW_BACKUP_ANDSEC_VAR "tw_backup_andsec"
-#define TW_BACKUP_SDEXT_VAR "tw_backup_sdext"
-#define TW_BACKUP_SP1_VAR "tw_backup_sp1"
-#define TW_BACKUP_SP2_VAR "tw_backup_sp2"
-#define TW_BACKUP_SP3_VAR "tw_backup_sp3"
-#define TW_BACKUP_AVG_IMG_RATE "tw_backup_avg_img_rate"
-#define TW_BACKUP_AVG_FILE_RATE "tw_backup_avg_file_rate"
-#define TW_BACKUP_AVG_FILE_COMP_RATE "tw_backup_avg_file_comp_rate"
-#define TW_BACKUP_SYSTEM_SIZE "tw_backup_system_size"
-#define TW_BACKUP_DATA_SIZE "tw_backup_data_size"
-#define TW_BACKUP_BOOT_SIZE "tw_backup_boot_size"
-#define TW_BACKUP_RECOVERY_SIZE "tw_backup_recovery_size"
-#define TW_BACKUP_CACHE_SIZE "tw_backup_cache_size"
-#define TW_BACKUP_ANDSEC_SIZE "tw_backup_andsec_size"
-#define TW_BACKUP_SDEXT_SIZE "tw_backup_sdext_size"
-#define TW_BACKUP_SP1_SIZE "tw_backup_sp1_size"
-#define TW_BACKUP_SP2_SIZE "tw_backup_sp2_size"
-#define TW_BACKUP_SP3_SIZE "tw_backup_sp3_size"
-#define TW_STORAGE_FREE_SIZE "tw_storage_free_size"
-#define TW_GENERATE_MD5_TEXT "tw_generate_md5_text"
-
-#define TW_RESTORE_TEXT "tw_restore_text"
-#define TW_RESTORE_SYSTEM_VAR "tw_restore_system"
-#define TW_RESTORE_DATA_VAR "tw_restore_data"
-#define TW_RESTORE_BOOT_VAR "tw_restore_boot"
-#define TW_RESTORE_RECOVERY_VAR "tw_restore_recovery"
-#define TW_RESTORE_CACHE_VAR "tw_restore_cache"
-#define TW_RESTORE_ANDSEC_VAR "tw_restore_andsec"
-#define TW_RESTORE_SDEXT_VAR "tw_restore_sdext"
-#define TW_RESTORE_SP1_VAR "tw_restore_sp1"
-#define TW_RESTORE_SP2_VAR "tw_restore_sp2"
-#define TW_RESTORE_SP3_VAR "tw_restore_sp3"
-#define TW_RESTORE_AVG_IMG_RATE "tw_restore_avg_img_rate"
-#define TW_RESTORE_AVG_FILE_RATE "tw_restore_avg_file_rate"
-#define TW_RESTORE_AVG_FILE_COMP_RATE "tw_restore_avg_file_comp_rate"
-#define TW_RESTORE_FILE_DATE "tw_restore_file_date"
-#define TW_VERIFY_MD5_TEXT "tw_verify_md5_text"
-#define TW_UPDATE_SYSTEM_DETAILS_TEXT "tw_update_system_details_text"
-
-#define TW_SHOW_SPAM_VAR "tw_show_spam"
-#define TW_COLOR_THEME_VAR "tw_color_theme"
-#define TW_VERSION_VAR "tw_version"
-#define TW_SORT_FILES_BY_DATE_VAR "tw_sort_files_by_date"
-#define TW_GUI_SORT_ORDER "tw_gui_sort_order"
-#define TW_ZIP_LOCATION_VAR "tw_zip_location"
-#define TW_ZIP_INTERNAL_VAR "tw_zip_internal"
-#define TW_ZIP_EXTERNAL_VAR "tw_zip_external"
-#define TW_FORCE_MD5_CHECK_VAR "tw_force_md5_check"
-#define TW_SKIP_MD5_CHECK_VAR "tw_skip_md5_check"
-#define TW_SKIP_MD5_GENERATE_VAR "tw_skip_md5_generate"
-#define TW_SIGNED_ZIP_VERIFY_VAR "tw_signed_zip_verify"
-#define TW_REBOOT_AFTER_FLASH_VAR "tw_reboot_after_flash_option"
-#define TW_TIME_ZONE_VAR "tw_time_zone"
-#define TW_RM_RF_VAR "tw_rm_rf"
-
-#define TW_BACKUPS_FOLDER_VAR "tw_backups_folder"
-
-#define TW_SP1_PARTITION_NAME_VAR "tw_sp1_name"
-#define TW_SP2_PARTITION_NAME_VAR "tw_sp2_name"
-#define TW_SP3_PARTITION_NAME_VAR "tw_sp3_name"
-
-#define TW_SDEXT_SIZE "tw_sdext_size"
-#define TW_SWAP_SIZE "tw_swap_size"
-#define TW_SDPART_FILE_SYSTEM "tw_sdpart_file_system"
-#define TW_TIME_ZONE_GUISEL "tw_time_zone_guisel"
-#define TW_TIME_ZONE_GUIOFFSET "tw_time_zone_guioffset"
-#define TW_TIME_ZONE_GUIDST "tw_time_zone_guidst"
-
-#define TW_ACTION_BUSY "tw_busy"
-
-#define TW_ALLOW_PARTITION_SDCARD "tw_allow_partition_sdcard"
-
-#define TW_SCREEN_OFF "tw_screen_off"
-
-#define TW_REBOOT_SYSTEM "tw_reboot_system"
-#define TW_REBOOT_RECOVERY "tw_reboot_recovery"
-#define TW_REBOOT_POWEROFF "tw_reboot_poweroff"
-#define TW_REBOOT_BOOTLOADER "tw_reboot_bootloader"
-
-#define TW_HAS_DUAL_STORAGE "tw_has_dual_storage"
-#define TW_USE_EXTERNAL_STORAGE "tw_use_external_storage"
-#define TW_HAS_INTERNAL "tw_has_internal"
-#define TW_INTERNAL_PATH "tw_internal_path" // /data/media or /internal
-#define TW_INTERNAL_MOUNT "tw_internal_mount" // /data or /internal
-#define TW_INTERNAL_LABEL "tw_internal_label" // data or internal
-#define TW_HAS_EXTERNAL "tw_has_external"
-#define TW_EXTERNAL_PATH "tw_external_path" // /sdcard or /external/sdcard2
-#define TW_EXTERNAL_MOUNT "tw_external_mount" // /sdcard or /external
-#define TW_EXTERNAL_LABEL "tw_external_label" // sdcard or external
-
-#define TW_HAS_DATA_MEDIA "tw_has_data_media"
-
-#define TW_HAS_BOOT_PARTITION "tw_has_boot_partition"
-#define TW_HAS_RECOVERY_PARTITION "tw_has_recovery_partition"
-#define TW_HAS_ANDROID_SECURE "tw_has_android_secure"
-#define TW_HAS_SDEXT_PARTITION "tw_has_sdext_partition"
-#define TW_HAS_USB_STORAGE "tw_has_usb_storage"
-#define TW_NO_BATTERY_PERCENT "tw_no_battery_percent"
-#define TW_POWER_BUTTON "tw_power_button"
-#define TW_SIMULATE_ACTIONS "tw_simulate_actions"
-#define TW_SIMULATE_FAIL "tw_simulate_fail"
-#define TW_DONT_UNMOUNT_SYSTEM "tw_dont_unmount_system"
-// #define TW_ALWAYS_RMRF "tw_always_rmrf"
-
-#define TW_SHOW_DUMLOCK "tw_show_dumlock"
-#define TW_HAS_INJECTTWRP "tw_has_injecttwrp"
-#define TW_INJECT_AFTER_ZIP "tw_inject_after_zip"
-#define TW_HAS_DATADATA "tw_has_datadata"
-#define TW_FLASH_ZIP_IN_PLACE "tw_flash_zip_in_place"
-#define TW_MIN_SYSTEM_SIZE "50" // minimum system size to allow a reboot
-#define TW_MIN_SYSTEM_VAR "tw_min_system"
-#define TW_DOWNLOAD_MODE "tw_download_mode"
-#define TW_IS_ENCRYPTED "tw_is_encrypted"
-#define TW_IS_DECRYPTED "tw_is_decrypted"
-#define TW_HAS_CRYPTO "tw_has_crypto"
-#define TW_CRYPTO_PASSWORD "tw_crypto_password"
-#define TW_DATA_BLK_DEVICE "tw_data_blk_device" // Original block device - not decrypted
-#define TW_SDEXT_DISABLE_EXT4 "tw_sdext_disable_ext4"
-
-// Also used:
-// tw_boot_is_mountable
-// tw_system_is_mountable
-// tw_data_is_mountable
-// tw_cache_is_mountable
-// tw_sdcext_is_mountable
-// tw_sdcint_is_mountable
-// tw_sd-ext_is_mountable
-// tw_sp1_is_mountable
-// tw_sp2_is_mountable
-// tw_sp3_is_mountable
-
-// Max archive size for tar backups before we split (1.5GB)
-#define MAX_ARCHIVE_SIZE 1610612736LLU
-
-#ifndef CUSTOM_LUN_FILE
-#define CUSTOM_LUN_FILE "/sys/devices/platform/usb_mass_storage/lun%d/file"
-#endif
-
-// For OpenRecoveryScript
-#define SCRIPT_FILE_CACHE "/cache/recovery/openrecoveryscript"
-#define SCRIPT_FILE_TMP "/tmp/openrecoveryscript"
-
-#endif // _VARIABLES_HEADER_
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _VARIABLES_HEADER_
+#define _VARIABLES_HEADER_
+
+#define TW_VERSION_STR "2.4.1.0"
+
+#define TW_USE_COMPRESSION_VAR "tw_use_compression"
+#define TW_IGNORE_IMAGE_SIZE "tw_ignore_image_size"
+#define TW_FILENAME "tw_filename"
+#define TW_ZIP_INDEX "tw_zip_index"
+#define TW_ZIP_QUEUE_COUNT "tw_zip_queue_count"
+
+#define MAX_BACKUP_NAME_LEN 64
+#define TW_BACKUP_TEXT "tw_backup_text"
+#define TW_BACKUP_NAME "tw_backup_name"
+#define TW_BACKUP_SYSTEM_VAR "tw_backup_system"
+#define TW_BACKUP_DATA_VAR "tw_backup_data"
+#define TW_BACKUP_BOOT_VAR "tw_backup_boot"
+#define TW_BACKUP_RECOVERY_VAR "tw_backup_recovery"
+#define TW_BACKUP_CACHE_VAR "tw_backup_cache"
+#define TW_BACKUP_ANDSEC_VAR "tw_backup_andsec"
+#define TW_BACKUP_SDEXT_VAR "tw_backup_sdext"
+#define TW_BACKUP_SP1_VAR "tw_backup_sp1"
+#define TW_BACKUP_SP2_VAR "tw_backup_sp2"
+#define TW_BACKUP_SP3_VAR "tw_backup_sp3"
+#define TW_BACKUP_AVG_IMG_RATE "tw_backup_avg_img_rate"
+#define TW_BACKUP_AVG_FILE_RATE "tw_backup_avg_file_rate"
+#define TW_BACKUP_AVG_FILE_COMP_RATE "tw_backup_avg_file_comp_rate"
+#define TW_BACKUP_SYSTEM_SIZE "tw_backup_system_size"
+#define TW_BACKUP_DATA_SIZE "tw_backup_data_size"
+#define TW_BACKUP_BOOT_SIZE "tw_backup_boot_size"
+#define TW_BACKUP_RECOVERY_SIZE "tw_backup_recovery_size"
+#define TW_BACKUP_CACHE_SIZE "tw_backup_cache_size"
+#define TW_BACKUP_ANDSEC_SIZE "tw_backup_andsec_size"
+#define TW_BACKUP_SDEXT_SIZE "tw_backup_sdext_size"
+#define TW_BACKUP_SP1_SIZE "tw_backup_sp1_size"
+#define TW_BACKUP_SP2_SIZE "tw_backup_sp2_size"
+#define TW_BACKUP_SP3_SIZE "tw_backup_sp3_size"
+#define TW_STORAGE_FREE_SIZE "tw_storage_free_size"
+#define TW_GENERATE_MD5_TEXT "tw_generate_md5_text"
+
+#define TW_RESTORE_TEXT "tw_restore_text"
+#define TW_RESTORE_SYSTEM_VAR "tw_restore_system"
+#define TW_RESTORE_DATA_VAR "tw_restore_data"
+#define TW_RESTORE_BOOT_VAR "tw_restore_boot"
+#define TW_RESTORE_RECOVERY_VAR "tw_restore_recovery"
+#define TW_RESTORE_CACHE_VAR "tw_restore_cache"
+#define TW_RESTORE_ANDSEC_VAR "tw_restore_andsec"
+#define TW_RESTORE_SDEXT_VAR "tw_restore_sdext"
+#define TW_RESTORE_SP1_VAR "tw_restore_sp1"
+#define TW_RESTORE_SP2_VAR "tw_restore_sp2"
+#define TW_RESTORE_SP3_VAR "tw_restore_sp3"
+#define TW_RESTORE_AVG_IMG_RATE "tw_restore_avg_img_rate"
+#define TW_RESTORE_AVG_FILE_RATE "tw_restore_avg_file_rate"
+#define TW_RESTORE_AVG_FILE_COMP_RATE "tw_restore_avg_file_comp_rate"
+#define TW_RESTORE_FILE_DATE "tw_restore_file_date"
+#define TW_VERIFY_MD5_TEXT "tw_verify_md5_text"
+#define TW_UPDATE_SYSTEM_DETAILS_TEXT "tw_update_system_details_text"
+
+#define TW_SHOW_SPAM_VAR "tw_show_spam"
+#define TW_COLOR_THEME_VAR "tw_color_theme"
+#define TW_VERSION_VAR "tw_version"
+#define TW_SORT_FILES_BY_DATE_VAR "tw_sort_files_by_date"
+#define TW_GUI_SORT_ORDER "tw_gui_sort_order"
+#define TW_ZIP_LOCATION_VAR "tw_zip_location"
+#define TW_ZIP_INTERNAL_VAR "tw_zip_internal"
+#define TW_ZIP_EXTERNAL_VAR "tw_zip_external"
+#define TW_FORCE_MD5_CHECK_VAR "tw_force_md5_check"
+#define TW_SKIP_MD5_CHECK_VAR "tw_skip_md5_check"
+#define TW_SKIP_MD5_GENERATE_VAR "tw_skip_md5_generate"
+#define TW_SIGNED_ZIP_VERIFY_VAR "tw_signed_zip_verify"
+#define TW_REBOOT_AFTER_FLASH_VAR "tw_reboot_after_flash_option"
+#define TW_TIME_ZONE_VAR "tw_time_zone"
+#define TW_RM_RF_VAR "tw_rm_rf"
+
+#define TW_BACKUPS_FOLDER_VAR "tw_backups_folder"
+
+#define TW_SP1_PARTITION_NAME_VAR "tw_sp1_name"
+#define TW_SP2_PARTITION_NAME_VAR "tw_sp2_name"
+#define TW_SP3_PARTITION_NAME_VAR "tw_sp3_name"
+
+#define TW_SDEXT_SIZE "tw_sdext_size"
+#define TW_SWAP_SIZE "tw_swap_size"
+#define TW_SDPART_FILE_SYSTEM "tw_sdpart_file_system"
+#define TW_TIME_ZONE_GUISEL "tw_time_zone_guisel"
+#define TW_TIME_ZONE_GUIOFFSET "tw_time_zone_guioffset"
+#define TW_TIME_ZONE_GUIDST "tw_time_zone_guidst"
+
+#define TW_ACTION_BUSY "tw_busy"
+
+#define TW_ALLOW_PARTITION_SDCARD "tw_allow_partition_sdcard"
+
+#define TW_SCREEN_OFF "tw_screen_off"
+
+#define TW_REBOOT_SYSTEM "tw_reboot_system"
+#define TW_REBOOT_RECOVERY "tw_reboot_recovery"
+#define TW_REBOOT_POWEROFF "tw_reboot_poweroff"
+#define TW_REBOOT_BOOTLOADER "tw_reboot_bootloader"
+
+#define TW_HAS_DUAL_STORAGE "tw_has_dual_storage"
+#define TW_USE_EXTERNAL_STORAGE "tw_use_external_storage"
+#define TW_HAS_INTERNAL "tw_has_internal"
+#define TW_INTERNAL_PATH "tw_internal_path" // /data/media or /internal
+#define TW_INTERNAL_MOUNT "tw_internal_mount" // /data or /internal
+#define TW_INTERNAL_LABEL "tw_internal_label" // data or internal
+#define TW_HAS_EXTERNAL "tw_has_external"
+#define TW_EXTERNAL_PATH "tw_external_path" // /sdcard or /external/sdcard2
+#define TW_EXTERNAL_MOUNT "tw_external_mount" // /sdcard or /external
+#define TW_EXTERNAL_LABEL "tw_external_label" // sdcard or external
+
+#define TW_HAS_DATA_MEDIA "tw_has_data_media"
+
+#define TW_HAS_BOOT_PARTITION "tw_has_boot_partition"
+#define TW_HAS_RECOVERY_PARTITION "tw_has_recovery_partition"
+#define TW_HAS_ANDROID_SECURE "tw_has_android_secure"
+#define TW_HAS_SDEXT_PARTITION "tw_has_sdext_partition"
+#define TW_HAS_USB_STORAGE "tw_has_usb_storage"
+#define TW_NO_BATTERY_PERCENT "tw_no_battery_percent"
+#define TW_POWER_BUTTON "tw_power_button"
+#define TW_SIMULATE_ACTIONS "tw_simulate_actions"
+#define TW_SIMULATE_FAIL "tw_simulate_fail"
+#define TW_DONT_UNMOUNT_SYSTEM "tw_dont_unmount_system"
+// #define TW_ALWAYS_RMRF "tw_always_rmrf"
+
+#define TW_SHOW_DUMLOCK "tw_show_dumlock"
+#define TW_HAS_INJECTTWRP "tw_has_injecttwrp"
+#define TW_INJECT_AFTER_ZIP "tw_inject_after_zip"
+#define TW_HAS_DATADATA "tw_has_datadata"
+#define TW_FLASH_ZIP_IN_PLACE "tw_flash_zip_in_place"
+#define TW_MIN_SYSTEM_SIZE "50" // minimum system size to allow a reboot
+#define TW_MIN_SYSTEM_VAR "tw_min_system"
+#define TW_DOWNLOAD_MODE "tw_download_mode"
+#define TW_IS_ENCRYPTED "tw_is_encrypted"
+#define TW_IS_DECRYPTED "tw_is_decrypted"
+#define TW_HAS_CRYPTO "tw_has_crypto"
+#define TW_CRYPTO_PASSWORD "tw_crypto_password"
+#define TW_DATA_BLK_DEVICE "tw_data_blk_device" // Original block device - not decrypted
+#define TW_SDEXT_DISABLE_EXT4 "tw_sdext_disable_ext4"
+
+// Also used:
+// tw_boot_is_mountable
+// tw_system_is_mountable
+// tw_data_is_mountable
+// tw_cache_is_mountable
+// tw_sdcext_is_mountable
+// tw_sdcint_is_mountable
+// tw_sd-ext_is_mountable
+// tw_sp1_is_mountable
+// tw_sp2_is_mountable
+// tw_sp3_is_mountable
+
+// Max archive size for tar backups before we split (1.5GB)
+#define MAX_ARCHIVE_SIZE 1610612736LLU
+
+#ifndef CUSTOM_LUN_FILE
+#define CUSTOM_LUN_FILE "/sys/devices/platform/usb_mass_storage/lun%d/file"
+#endif
+
+#ifndef TW_BRIGHTNESS_PATH
+#define TW_BRIGHTNESS_PATH /nobrightness
+#endif
+
+// For OpenRecoveryScript
+#define SCRIPT_FILE_CACHE "/cache/recovery/openrecoveryscript"
+#define SCRIPT_FILE_TMP "/tmp/openrecoveryscript"
+
+#endif // _VARIABLES_HEADER_