From 01f4e035aa0833252b99dcbda0e08a327ba8bf3d Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Fri, 3 Feb 2017 15:30:52 -0600 Subject: Improve backup display names with emulated storage -Change backup display name to say that we are excluding storage -Add warning message during backup of any partition with data media -Also eliminate unused variable from twrpTar class Maybe this will make the people in issue 276 happy, but probably not because they already lost their data, or because the warning text is yellow instead of red. https://github.com/TeamWin/Team-Win-Recovery-Project/issues/276 Change-Id: I98303fe7f6b7a25fea029637c90145258d41ee46 --- gui/theme/common/languages/en.xml | 2 ++ partition.cpp | 3 ++- partitionmanager.cpp | 26 ++++++++++++++++++++++---- partitions.hpp | 1 + twrpTar.cpp | 1 - twrpTar.hpp | 1 - 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml index d91131293..72ef5affd 100644 --- a/gui/theme/common/languages/en.xml +++ b/gui/theme/common/languages/en.xml @@ -19,6 +19,7 @@ Recovery Cache Data + Data (excl. storage) SDCard Internal Storage Micro SDCard @@ -595,6 +596,7 @@ Removing all files under '{1}' Wiping data without wiping /data/media ... Backing up {1}... + Backups of {1} do not include any files in internal storage such as pictures or downloads. Backing Up Backup file size for '{1}' is 0 bytes. WARNING: This /data backup was made with {1} file system! The backup may not boot unless you change back to {1}. diff --git a/partition.cpp b/partition.cpp index 464438811..5cf017987 100644 --- a/partition.cpp +++ b/partition.cpp @@ -2210,7 +2210,8 @@ bool TWPartition::Backup_Tar(PartitionSettings *part_settings, pid_t *tar_fork_p Backup_FileName = Backup_Name + "." + Current_File_System + ".win"; Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; - tar.has_data_media = Has_Data_Media; + if (Has_Data_Media) + gui_msg(Msg(msg::kWarning, "backup_storage_warning=Backups of {1} do not include any files in internal storage such as pictures or downloads.")(Display_Name)); tar.part_settings = part_settings; tar.backup_exclusions = &backup_exclusions; tar.setdir(Backup_Path); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index f94b6aa22..9afc67727 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -2383,8 +2383,8 @@ void TWPartitionManager::Translate_Partition(const char* path, const char* resou TWPartition* part = PartitionManager.Find_Partition_By_Path(path); if (part) { if (part->Is_Adopted_Storage) { + part->Backup_Display_Name = part->Display_Name + " - " + gui_lookup("data_backup", "Data (excl. storage)"); part->Display_Name = part->Display_Name + " - " + gui_lookup("data", "Data"); - part->Backup_Display_Name = part->Display_Name; part->Storage_Name = part->Storage_Name + " - " + gui_lookup("adopted_storage", "Adopted Storage"); } else { part->Display_Name = gui_lookup(resource_name, default_value); @@ -2395,6 +2395,22 @@ void TWPartitionManager::Translate_Partition(const char* path, const char* resou } } +void TWPartitionManager::Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value, const char* backup_name, const char* backup_default) { + TWPartition* part = PartitionManager.Find_Partition_By_Path(path); + if (part) { + if (part->Is_Adopted_Storage) { + part->Backup_Display_Name = part->Display_Name + " - " + gui_lookup(backup_name, backup_default); + part->Display_Name = part->Display_Name + " - " + gui_lookup("data", "Data"); + part->Storage_Name = part->Storage_Name + " - " + gui_lookup("adopted_storage", "Adopted Storage"); + } else { + part->Display_Name = gui_lookup(resource_name, default_value); + part->Backup_Display_Name = gui_lookup(backup_name, backup_default); + if (part->Is_Storage) + part->Storage_Name = gui_lookup(storage_resource_name, storage_default_value); + } + } +} + void TWPartitionManager::Translate_Partition_Display_Names() { LOGINFO("Translating partition display names\n"); Translate_Partition("/system", "system", "System"); @@ -2402,17 +2418,19 @@ void TWPartitionManager::Translate_Partition_Display_Names() { Translate_Partition("/vendor", "vendor", "Vendor"); Translate_Partition("/vendor_image", "vendor_image", "Vendor Image"); Translate_Partition("/cache", "cache", "Cache"); - Translate_Partition("/data", "data", "Data", "internal", "Internal Storage"); Translate_Partition("/boot", "boot", "Boot"); Translate_Partition("/recovery", "recovery", "Recovery"); if (!datamedia) { + Translate_Partition("/data", "data", "Data", "internal", "Internal Storage"); Translate_Partition("/sdcard", "sdcard", "SDCard", "sdcard", "SDCard"); Translate_Partition("/internal_sd", "sdcard", "SDCard", "sdcard", "SDCard"); Translate_Partition("/internal_sdcard", "sdcard", "SDCard", "sdcard", "SDCard"); Translate_Partition("/emmc", "sdcard", "SDCard", "sdcard", "SDCard"); + } else { + Translate_Partition("/data", "data", "Data", "internal", "Internal Storage", "data_backup", "Data (excl. storage)"); } - Translate_Partition("/external_sd", "microsd", "Micro SDCard", "microsd", "Micro SDCard"); - Translate_Partition("/external_sdcard", "microsd", "Micro SDCard", "microsd", "Micro SDCard"); + Translate_Partition("/external_sd", "microsd", "Micro SDCard", "microsd", "Micro SDCard", "data_backup", "Data (excl. storage)"); + Translate_Partition("/external_sdcard", "microsd", "Micro SDCard", "microsd", "Micro SDCard", "data_backup", "Data (excl. storage)"); Translate_Partition("/usb-otg", "usbotg", "USB OTG", "usbotg", "USB OTG"); Translate_Partition("/sd-ext", "sdext", "SD-EXT"); diff --git a/partitions.hpp b/partitions.hpp index 450e8815b..0f0e6fd30 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -285,6 +285,7 @@ public: bool Remove_MTP_Storage(unsigned int Storage_ID); // Adds or removes an MTP Storage partition void Translate_Partition(const char* path, const char* resource_name, const char* default_value); void Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value); + void Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value, const char* backup_name, const char* backup_default); void Translate_Partition_Display_Names(); // Updates display names based on translations void Decrypt_Adopted(); // Attempt to identy and decrypt any adopted storage partitions void Remove_Partition_By_Path(string Path); // Removes / erases a partition entry from the partition list diff --git a/twrpTar.cpp b/twrpTar.cpp index 7e4d29a7a..fa836fd51 100644 --- a/twrpTar.cpp +++ b/twrpTar.cpp @@ -67,7 +67,6 @@ twrpTar::twrpTar(void) { userdata_encryption = 0; use_compression = 0; split_archives = 0; - has_data_media = 0; pigz_pid = 0; oaes_pid = 0; Total_Backup_Size = 0; diff --git a/twrpTar.hpp b/twrpTar.hpp index 92674ee61..b07b06f49 100644 --- a/twrpTar.hpp +++ b/twrpTar.hpp @@ -62,7 +62,6 @@ public: int userdata_encryption; int use_compression; int split_archives; - int has_data_media; string backup_name; int progress_pipe_fd; string partition_name; -- cgit v1.2.3