summaryrefslogtreecommitdiffstats
path: root/data.cpp
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2019-01-09 02:06:57 +0100
committerDees Troy <dees_troy@teamw.in>2019-03-18 04:49:38 +0100
commit19874f14699edf411951a62f5ac880ca6a84d824 (patch)
tree30257d8752e5ecdc3883b7b582c93d866aa11a07 /data.cpp
parentVibration: allow BoardConfig to disable vibration for a device. (diff)
downloadandroid_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar.gz
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar.bz2
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar.lz
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar.xz
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.tar.zst
android_bootable_recovery-19874f14699edf411951a62f5ac880ca6a84d824.zip
Diffstat (limited to '')
-rwxr-xr-xdata.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/data.cpp b/data.cpp
index cf8349ba8..0ece4e793 100755
--- a/data.cpp
+++ b/data.cpp
@@ -1038,33 +1038,38 @@ void DataManager::Output_Version(void)
string Path;
char version[255];
- if (!PartitionManager.Mount_By_Path("/cache", false)) {
- LOGINFO("Unable to mount '%s' to write version number.\n", Path.c_str());
- return;
+ std::string cacheDir = TWFunc::get_cache_dir();
+ std::string recoveryCacheDir = cacheDir + "recovery/";
+
+ if (cacheDir == NON_AB_CACHE_DIR) {
+ if (!PartitionManager.Mount_By_Path(NON_AB_CACHE_DIR, false)) {
+ LOGINFO("Unable to mount '%s' to write version number.\n", Path.c_str());
+ return;
+ }
}
- if (!TWFunc::Path_Exists("/cache/recovery/.")) {
- LOGINFO("Recreating /cache/recovery folder.\n");
- if (mkdir("/cache/recovery", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0) {
- LOGERR("DataManager::Output_Version -- Unable to make /cache/recovery\n");
+ if (!TWFunc::Path_Exists(recoveryCacheDir)) {
+ LOGINFO("Recreating %s folder.\n", recoveryCacheDir.c_str());
+ if (mkdir(recoveryCacheDir.c_str(), S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0) {
+ LOGERR("DataManager::Output_Version -- Unable to make %s: %s\n", recoveryCacheDir.c_str(), strerror(errno));
return;
}
}
- Path = "/cache/recovery/.version";
- if (TWFunc::Path_Exists(Path)) {
- unlink(Path.c_str());
+ std::string verPath = recoveryCacheDir + ".version";
+ if (TWFunc::Path_Exists(verPath)) {
+ unlink(verPath.c_str());
}
- FILE *fp = fopen(Path.c_str(), "w");
+ FILE *fp = fopen(verPath.c_str(), "w");
if (fp == NULL) {
- gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
+ gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(verPath)(strerror(errno)));
return;
}
strcpy(version, TW_VERSION_STR);
fwrite(version, sizeof(version[0]), strlen(version) / sizeof(version[0]), fp);
fclose(fp);
- TWFunc::copy_file("/etc/recovery.fstab", "/cache/recovery/recovery.fstab", 0644);
+ TWFunc::copy_file("/etc/recovery.fstab", recoveryCacheDir + "recovery.fstab", 0644);
PartitionManager.Output_Storage_Fstab();
sync();
- LOGINFO("Version number saved to '%s'\n", Path.c_str());
+ LOGINFO("Version number saved to '%s'\n", verPath.c_str());
#endif
}
@@ -1077,10 +1082,6 @@ void DataManager::ReadSettingsFile(void)
GetValue(TW_IS_ENCRYPTED, is_enc);
GetValue(TW_HAS_DATA_MEDIA, has_data_media);
- if (is_enc == 1 && has_data_media == 1) {
- LOGINFO("Cannot load settings -- encrypted.\n");
- return;
- }
memset(mkdir_path, 0, sizeof(mkdir_path));
memset(settings_file, 0, sizeof(settings_file));