Use /persist as Qualcomm time fix source during early boot
* /persist can be mounted early while TWRP is parsing the fstab so as soon as the partition is parsed, mount and adjust the time accordingly. * Store a backup settings file on /persist. Having a 2nd copy of the settings file in the /persist partition allows for early reading of the file and adjust timezone and brightness to user preference while still on TWRP splash. * Add the qcom ats time offset in TWRP settings file and use it if no better ats file is found. This will also allow devices with a persist partition, but no ats files in it, to adjust the time offset during early boot. * Use /persist/time/ as Qualcomm time fix source, based on Xuefer <xuefer@gmail.com> patch: https://gerrit.omnirom.org/c/27265/ https://gerrit.omnirom.org/c/24384/ Change-Id: I6c21538eec58d87edfb639d9ce3871f33b886c1d
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user