Set /data/recovery for Settings
* Test: TWRP boots, settings saves, Change TWRP Folder works
Change-Id: Iaae45064815a4adc55e1116f2c51fba869b284b5
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit f923110ae01d45f5afb3eccf734d82b9c0b4795e)
diff --git a/data.cpp b/data.cpp
index 07e5c1f..22efb18 100755
--- a/data.cpp
+++ b/data.cpp
@@ -1149,7 +1149,7 @@
memset(mkdir_path, 0, sizeof(mkdir_path));
memset(settings_file, 0, sizeof(settings_file));
- sprintf(mkdir_path, "%s%s", GetSettingsStoragePath().c_str(), GetStrValue(TW_RECOVERY_FOLDER_VAR).c_str());
+ sprintf(mkdir_path, "%s%s", GetSettingsStoragePath().c_str(), GetStrValue(TW_RECOVERY_NAME).c_str());
sprintf(settings_file, "%s/%s", mkdir_path, TW_SETTINGS_FILE);
if (!PartitionManager.Mount_Settings_Storage(false))
@@ -1194,7 +1194,6 @@
void DataManager::LoadTWRPFolderInfo(void)
{
- string mainPath = GetCurrentStoragePath();
SetValue(TW_RECOVERY_FOLDER_VAR, TWFunc::Check_For_TwrpFolder());
- mBackingFile = mainPath + GetStrValue(TW_RECOVERY_FOLDER_VAR) + '/' + TW_SETTINGS_FILE;
+ mBackingFile = GetSettingsStoragePath() + GetStrValue(TW_RECOVERY_NAME) + '/' + TW_SETTINGS_FILE;
}
diff --git a/gui/action.cpp b/gui/action.cpp
index 61a3bed..d643daa 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1138,7 +1138,7 @@
if (has_datamedia) {
ret_val = PartitionManager.Wipe_Media_From_Data();
} else {
- ret_val = PartitionManager.Wipe_By_Path(DataManager::GetSettingsStoragePath());
+ ret_val = PartitionManager.Wipe_By_Path(DataManager::GetCurrentStoragePath());
}
} else if (arg == "EXTERNAL") {
string External_Path;
@@ -1188,7 +1188,7 @@
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(wipe_path));
ret_val = false;
break;
- } else if (wipe_path == DataManager::GetSettingsStoragePath()) {
+ } else if (wipe_path == DataManager::GetCurrentStoragePath()) {
arg = wipe_path;
}
} else {
@@ -2321,7 +2321,7 @@
int GUIAction::applycustomtwrpfolder(string arg __unused)
{
operation_start("ChangingTWRPFolder");
- string storageFolder = DataManager::GetSettingsStoragePath();
+ string storageFolder = DataManager::GetCurrentStoragePath();
string newFolder = storageFolder + '/' + arg;
string newBackupFolder = newFolder + "/BACKUPS/" + DataManager::GetStrValue("device_id");
string prevFolder = storageFolder + DataManager::GetStrValue(TW_RECOVERY_FOLDER_VAR);
@@ -2345,7 +2345,6 @@
if (ret) {
DataManager::SetValue(TW_RECOVERY_FOLDER_VAR, '/' + arg);
DataManager::SetValue(TW_BACKUPS_FOLDER_VAR, newBackupFolder);
- DataManager::mBackingFile = newFolder + '/' + TW_SETTINGS_FILE;
}
operation_end((int)!ret);
return 0;
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 6f55065..a848300 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -475,9 +475,7 @@
}
void TWPartitionManager::Setup_Settings_Storage_Partition(TWPartition* Part) {
- DataManager::SetValue("tw_settings_path", Part->Storage_Path);
DataManager::SetValue("tw_storage_path", Part->Storage_Path);
- LOGINFO("Settings storage is '%s'\n", Part->Storage_Path.c_str());
}
void TWPartitionManager::Setup_Android_Secure_Location(TWPartition* Part) {
@@ -1811,7 +1809,7 @@
}
dat->Symlink_Path = dat->Storage_Path;
DataManager::SetValue("tw_storage_path", dat->Symlink_Path);
- DataManager::SetValue("tw_settings_path", dat->Symlink_Path);
+ DataManager::SetValue("tw_settings_path", TW_STORAGE_PATH);
LOGINFO("New storage path after decryption: %s\n", dat->Storage_Path.c_str());
DataManager::LoadTWRPFolderInfo();
diff --git a/variables.h b/variables.h
index e11aa26..7d28f61 100755
--- a/variables.h
+++ b/variables.h
@@ -22,6 +22,7 @@
#define TW_SETTINGS_FILE ".twrps"
#define TW_RECOVERY_NAME "TWRP"
#define TW_DEFAULT_RECOVERY_FOLDER "/" TW_RECOVERY_NAME
+#define TW_STORAGE_PATH "/data/recovery/"
#define TW_USE_COMPRESSION_VAR "tw_use_compression"
#define TW_FILENAME "tw_filename"
#define TW_ZIP_INDEX "tw_zip_index"