persist logs: remove persist from available log directories in
partitions.
Too many problems have been reported for TWRP attempting to store
logs in the persist partition. Selinux denials have caused issues
booting Android, and filling up persist has caused IMEI issues.
This patchset will remove persist from the list of available log
directories by default in order to avoid these and other possible
issues.
Change-Id: I9f5347875a6cab24ab83ad48476b17a174e65c43
diff --git a/data.cpp b/data.cpp
index bf6e33b..e6f1ac0 100755
--- a/data.cpp
+++ b/data.cpp
@@ -273,44 +273,6 @@
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();
@@ -319,15 +281,6 @@
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;
diff --git a/data.hpp b/data.hpp
index 4770ed5..bb73c41 100755
--- a/data.hpp
+++ b/data.hpp
@@ -23,8 +23,6 @@
#include <pthread.h>
#include "infomanager.hpp"
-#define PERSIST_SETTINGS_FILE "/persist/.twrps"
-
using namespace std;
class DataManager
diff --git a/partition.cpp b/partition.cpp
index 82cb944..f753fdb 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -605,7 +605,6 @@
bool mounted = Is_Mounted();
if (mounted || Mount(false)) {
// Read the backup settings file
- DataManager::LoadPersistValues();
TWFunc::Fixup_Time_On_Boot("/persist/time/");
if (!mounted)
UnMount(false);
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index ae1d133..2ac4c95 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -761,7 +761,7 @@
PartitionManager.Mount_By_Path(src, false);
PartitionManager.Mount_By_Path(dst, false);
if (!Path_Exists(src)) {
- LOGINFO("Unable to find source file %s\n", src.c_str());
+ LOGINFO("Path %s does not exist. Unable to copy %s\n", src.c_str(), dst.c_str());
return -1;
}
std::ifstream srcfile(src.c_str(), ios::binary);
@@ -1250,11 +1250,8 @@
std::string TWFunc::get_log_dir() {
if (PartitionManager.Find_Partition_By_Path(CACHE_LOGS_DIR) == NULL) {
if (PartitionManager.Find_Partition_By_Path(DATA_LOGS_DIR) == NULL) {
- if (PartitionManager.Find_Partition_By_Path(PERSIST_LOGS_DIR) == NULL) {
- LOGINFO("Unable to find a directory to store TWRP logs.");
- return "";
- }
- return PERSIST_LOGS_DIR;
+ LOGINFO("Unable to find a directory to store TWRP logs.");
+ return "";
} else {
return DATA_LOGS_DIR;
}
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 9715d78..d185398 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -38,7 +38,6 @@
#define CACHE_LOGS_DIR "/cache/" // For devices with a dedicated cache partition
#define DATA_LOGS_DIR "/data/" // For devices that do not have a dedicated cache partition
-#define PERSIST_LOGS_DIR "/persist/" // For devices with neither cache or dedicated data partition
typedef enum
{