summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'data.cpp')
-rw-r--r--data.cpp70
1 files changed, 34 insertions, 36 deletions
diff --git a/data.cpp b/data.cpp
index eda23399a..20b608918 100644
--- a/data.cpp
+++ b/data.cpp
@@ -91,7 +91,6 @@ void DataManager::sanitize_device_id(char* device_id) {
void DataManager::get_device_id(void) {
FILE *fp;
- size_t i;
char line[2048];
char hardware_id[HWID_MAX] = { 0 };
char device_id[DEVID_MAX] = { 0 };
@@ -104,7 +103,7 @@ void DataManager::get_device_id(void) {
if (strcmp(model_id, "error") != 0) {
LOGINFO("=> product model: '%s'\n", model_id);
// Replace spaces with underscores
- for (i = 0; i < strlen(model_id); i++) {
+ for (size_t i = 0; i < strlen(model_id); i++) {
if (model_id[i] == ' ')
model_id[i] = '_';
}
@@ -253,7 +252,7 @@ int DataManager::LoadValues(const string& filename)
pthread_mutex_unlock(&m_valuesLock);
string current = GetCurrentStoragePath();
TWPartition* Part = PartitionManager.Find_Partition_By_Path(current);
- if(!Part)
+ if (!Part)
Part = PartitionManager.Get_Default_Storage_Partition();
if (Part && current != Part->Storage_Path && Part->Mount(false)) {
LOGINFO("LoadValues setting storage path to '%s'\n", Part->Storage_Path.c_str());
@@ -536,7 +535,7 @@ void DataManager::SetDefaultValues()
mPersist.SetValue("tw_action_vibrate", "160");
TWPartition *store = PartitionManager.Get_Default_Storage_Partition();
- if(store)
+ if (store)
mPersist.SetValue("tw_storage_path", store->Storage_Path);
else
mPersist.SetValue("tw_storage_path", "/");
@@ -753,7 +752,7 @@ void DataManager::SetDefaultValues()
string maxbrightpath = findbright.insert(findbright.rfind('/') + 1, "max_");
if (TWFunc::Path_Exists(maxbrightpath)) {
ifstream maxVal(maxbrightpath.c_str());
- if(maxVal >> maxBrightness) {
+ if (maxVal >> maxBrightness) {
LOGINFO("Got max brightness %s from '%s'\n", maxBrightness.c_str(), maxbrightpath.c_str());
} else {
// Something went wrong, set that to indicate error
@@ -873,38 +872,37 @@ int DataManager::GetMagicValue(const string& varName, string& value)
}
else if (varName == "tw_cpu_temp")
{
- int tw_no_cpu_temp;
- GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
- if (tw_no_cpu_temp == 1) return -1;
-
- 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)
- {
+ int tw_no_cpu_temp;
+ GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
+ if (tw_no_cpu_temp == 1) return -1;
+
+ string cpu_temp_file;
+ static unsigned long convert_temp = 0;
+ static time_t cpuSecCheck = 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;
+ 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;
+ 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);
- if (convert_temp >= 150)
- convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
- cpuSecCheck = curTime.tv_sec + 5;
- }
- value = TWFunc::to_string(convert_temp);
- return 0;
+ convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
+ if (convert_temp <= 0)
+ convert_temp = strtoul(results.c_str(), NULL, 0);
+ if (convert_temp >= 150)
+ convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
+ cpuSecCheck = curTime.tv_sec + 5;
+ }
+ value = TWFunc::to_string(convert_temp);
+ return 0;
}
else if (varName == "tw_battery")
{
@@ -924,7 +922,7 @@ int DataManager::GetMagicValue(const string& varName, string& value)
#else
FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
#endif
- if (cap){
+ if (cap) {
fgets(cap_s, 4, cap);
fclose(cap);
lastVal = atoi(cap_s);
@@ -997,7 +995,7 @@ void DataManager::ReadSettingsFile(void)
#ifndef TW_OEM_BUILD
// Load up the values for TWRP - Sleep to let the card be ready
char mkdir_path[255], settings_file[255];
- int is_enc, has_dual, use_ext, has_data_media, has_ext;
+ int is_enc, has_data_media;
GetValue(TW_IS_ENCRYPTED, is_enc);
GetValue(TW_HAS_DATA_MEDIA, has_data_media);