summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
authornkk71 <nkk71x@gmail.com>2017-12-16 15:26:42 +0100
committerDees Troy <dees_troy@teamw.in>2018-01-17 20:42:17 +0100
commit98fc399c2660727a6bde66e1a51e8460aaf3c7e7 (patch)
tree50626f61a9be342328cbdc46016427c893482cad /data.cpp
parentMerge "Relink adbd needed in android 8.1" into android-8.1 (diff)
downloadandroid_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar.gz
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar.bz2
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar.lz
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar.xz
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.tar.zst
android_bootable_recovery-98fc399c2660727a6bde66e1a51e8460aaf3c7e7.zip
Diffstat (limited to '')
-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;