summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'data.cpp')
-rw-r--r--data.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/data.cpp b/data.cpp
index 6566bcd22..a4cb464c2 100644
--- a/data.cpp
+++ b/data.cpp
@@ -40,6 +40,7 @@
#include "data.hpp"
#include "partitions.hpp"
#include "twrp-functions.hpp"
+#include "gui/blanktimer.hpp"
#ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
#include "cutils/properties.h"
@@ -62,6 +63,7 @@ map<string, DataManager::TStrIntPair> DataManager::mValues;
map<string, string> DataManager::mConstValues;
string DataManager::mBackingFile;
int DataManager::mInitialized = 0;
+extern blanktimer blankTimer;
// Device ID functions
void DataManager::sanitize_device_id(char* device_id) {
@@ -429,7 +431,10 @@ int DataManager::SetValue(const string varName, string value, int persist /* = 0
if (pos->second.second != 0)
SaveValues();
- gui_notifyVarChange(varName.c_str(), value.c_str());
+ if (varName == "tw_screen_timeout_secs")
+ blankTimer.setTime(atoi(value.c_str()));
+ else
+ gui_notifyVarChange(varName.c_str(), value.c_str());
return 0;
}
@@ -849,6 +854,31 @@ void DataManager::SetDefaultValues()
mValues.insert(make_pair("tw_terminal_state", make_pair("0", 0)));
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_screen_timeout_secs", make_pair("60", 1)));
+#ifdef TW_MAX_BRIGHTNESS
+ if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
+ LOGI("TW_BRIGHTNESS_PATH := %s\n", EXPAND(TW_BRIGHTNESS_PATH));
+ mConstValues.insert(make_pair("tw_has_brightnesss_file", "1"));
+ mConstValues.insert(make_pair("tw_brightness_file", EXPAND(TW_BRIGHTNESS_PATH)));
+ ostringstream val100, val25, val50, val75;
+ int value = TW_MAX_BRIGHTNESS;
+ val100 << value;
+ mConstValues.insert(make_pair("tw_brightness_100", val100.str()));
+ value = TW_MAX_BRIGHTNESS * 0.25;
+ val25 << value;
+ mConstValues.insert(make_pair("tw_brightness_25", val25.str()));
+ value = TW_MAX_BRIGHTNESS * 0.5;
+ val50 << value;
+ mConstValues.insert(make_pair("tw_brightness_50", val50.str()));
+ value = TW_MAX_BRIGHTNESS * 0.75;
+ val75 << value;
+ mConstValues.insert(make_pair("tw_brightness_75", val75.str()));
+ mValues.insert(make_pair("tw_brightness", make_pair(val100.str(), 1)));
+ mValues.insert(make_pair("tw_brightness_display", make_pair("100", 1)));
+ } else {
+ mConstValues.insert(make_pair("tw_has_brightnesss_file", "0"));
+ }
+#endif
}
// Magic Values
@@ -998,6 +1028,14 @@ void DataManager::ReadSettingsFile(void)
PartitionManager.Mount_By_Path(ext_path, 0);
}
update_tz_environment_variables();
+#ifdef TW_MAX_BRIGHTNESS
+ if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
+ string brightness_path = EXPAND(TW_BRIGHTNESS_PATH);
+ string brightness_value = GetStrValue("tw_brightness");
+ LOGI("writing %s to brightness\n", brightness_value.c_str());
+ TWFunc::write_file(brightness_path, brightness_value);
+ }
+#endif
}
string DataManager::GetCurrentStoragePath(void)