summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'data.cpp')
-rw-r--r--data.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/data.cpp b/data.cpp
index 599b5c0d8..4dfbde2d0 100644
--- a/data.cpp
+++ b/data.cpp
@@ -230,7 +230,7 @@ int DataManager::ResetDefaults()
int DataManager::LoadValues(const string& filename)
{
- string str, dev_id;
+ string dev_id;
if (!mInitialized)
SetDefaultValues();
@@ -263,6 +263,44 @@ int DataManager::LoadValues(const string& filename)
return 0;
}
+int DataManager::LoadPersistValues(void)
+{
+ static bool loaded = false;
+ string dev_id;
+
+ // Only run this function once, and make sure normal settings file has not yet been read
+ if (loaded || !mBackingFile.empty() || !TWFunc::Path_Exists(PERSIST_SETTINGS_FILE))
+ return -1;
+
+ LOGINFO("Attempt to load settings from /persist settings file...\n");
+
+ if (!mInitialized)
+ SetDefaultValues();
+
+ GetValue("device_id", dev_id);
+ mPersist.SetFile(PERSIST_SETTINGS_FILE);
+ mPersist.SetFileVersion(FILE_VERSION);
+
+ // Read in the file, if possible
+ pthread_mutex_lock(&m_valuesLock);
+ mPersist.LoadValues();
+
+#ifndef TW_NO_SCREEN_TIMEOUT
+ blankTimer.setTime(mPersist.GetIntValue("tw_screen_timeout_secs"));
+#endif
+
+ update_tz_environment_variables();
+ TWFunc::Set_Brightness(GetStrValue("tw_brightness"));
+
+ pthread_mutex_unlock(&m_valuesLock);
+
+ /* Don't set storage nor backup paths this early */
+
+ loaded = true;
+
+ return 0;
+}
+
int DataManager::Flush()
{
return SaveValues();
@@ -271,6 +309,15 @@ int DataManager::Flush()
int DataManager::SaveValues()
{
#ifndef TW_OEM_BUILD
+ if (PartitionManager.Mount_By_Path("/persist", false)) {
+ mPersist.SetFile(PERSIST_SETTINGS_FILE);
+ mPersist.SetFileVersion(FILE_VERSION);
+ pthread_mutex_lock(&m_valuesLock);
+ mPersist.SaveValues();
+ pthread_mutex_unlock(&m_valuesLock);
+ LOGINFO("Saved settings file values to %s\n", PERSIST_SETTINGS_FILE);
+ }
+
if (mBackingFile.empty())
return -1;
@@ -284,7 +331,7 @@ int DataManager::SaveValues()
pthread_mutex_unlock(&m_valuesLock);
tw_set_default_metadata(mBackingFile.c_str());
- LOGINFO("Saved settings file values\n");
+ LOGINFO("Saved settings file values to '%s'\n", mBackingFile.c_str());
#endif // ifdef TW_OEM_BUILD
return 0;
}
@@ -353,7 +400,7 @@ int DataManager::GetValue(const string& varName, float& value)
return 0;
}
-unsigned long long DataManager::GetValue(const string& varName, unsigned long long& value)
+int DataManager::GetValue(const string& varName, unsigned long long& value)
{
string data;