summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
authorJenkins <bigbiff@teamw.in>2014-10-03 02:22:21 +0200
committerDees Troy <dees_troy@teamw.in>2014-10-14 15:08:11 +0200
commit1710bf254756d49355e9156ba1907545addfb319 (patch)
tree063fab21b02cb2a9ded53535ad19a4b4746f8a07 /data.cpp
parentAdd support for TrueType fonts (diff)
downloadandroid_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar.gz
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar.bz2
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar.lz
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar.xz
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.tar.zst
android_bootable_recovery-1710bf254756d49355e9156ba1907545addfb319.zip
Diffstat (limited to 'data.cpp')
-rw-r--r--data.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/data.cpp b/data.cpp
index be851584e..0e46b3bdb 100644
--- a/data.cpp
+++ b/data.cpp
@@ -72,6 +72,7 @@ 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
@@ -353,7 +354,6 @@ int DataManager::GetValue(const string varName, string& value)
// Handle magic values
if (GetMagicValue(localStr, value) == 0)
return 0;
-
map<string, string>::iterator constPos;
constPos = mConstValues.find(localStr);
if (constPos != mConstValues.end())
@@ -660,6 +660,23 @@ void DataManager::SetDefaultValues()
#else
mConstValues.insert(make_pair(TW_NO_BATTERY_PERCENT, "0"));
#endif
+#ifdef TW_NO_CPU_TEMP
+ printf("TW_NO_CPU_TEMP := true\n");
+ mConstValues.insert(make_pair("tw_no_cpu_temp", "1"));
+#else
+ string cpu_temp_file;
+#ifdef TW_CUSTOM_CPU_TEMP_PATH
+ cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
+#else
+ cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
+#endif
+ if (TWFunc::Path_Exists(cpu_temp_file)) {
+ mConstValues.insert(make_pair("tw_no_cpu_temp", "0"));
+ } else {
+ LOGINFO("CPU temperature file '%s' not found, disabling CPU temp.\n", cpu_temp_file.c_str());
+ mConstValues.insert(make_pair("tw_no_cpu_temp", "1"));
+ }
+#endif
#ifdef TW_CUSTOM_POWER_BUTTON
printf("TW_POWER_BUTTON := %s\n", EXPAND(TW_CUSTOM_POWER_BUTTON));
mConstValues.insert(make_pair(TW_POWER_BUTTON, EXPAND(TW_CUSTOM_POWER_BUTTON)));
@@ -862,13 +879,41 @@ int DataManager::GetMagicValue(const string varName, string& value)
value = tmp;
return 0;
}
+ else if (varName == "tw_cpu_temp")
+ {
+ string cpu_temp_file;
+ static unsigned long convert_temp = 0;
+ static time_t cpuSecCheck = 0;
+ int divisor = 0;
+ struct timeval curTime;
+ string results;
+
+ gettimeofday(&curTime, NULL);
+ if (curTime.tv_sec > cpuSecCheck)
+ {
+#ifdef TW_CUSTOM_CPU_TEMP_PATH
+ cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
+ if (TWFunc::read_file(cpu_temp_file, results) != 0)
+ return -1;
+#else
+ cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
+ if (TWFunc::read_file(cpu_temp_file, results) != 0)
+ return -1;
+#endif
+ convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
+ if (convert_temp <= 0)
+ convert_temp = strtoul(results.c_str(), NULL, 0);
+ cpuSecCheck = curTime.tv_sec + 5;
+ }
+ value = TWFunc::to_string(convert_temp);
+ return 0;
+ }
else if (varName == "tw_battery")
{
char tmp[16];
static char charging = ' ';
static int lastVal = -1;
static time_t nextSecCheck = 0;
-
struct timeval curTime;
gettimeofday(&curTime, NULL);
if (curTime.tv_sec > nextSecCheck)