Fix adopted storage when andsec flag is present
Change-Id: If903d838abc920f952f243482338188c15bb1dbf
diff --git a/partition.cpp b/partition.cpp
index df03336..3545634 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -2526,6 +2526,17 @@
cryptfs_revert_ext_volume(part_guid);
ret = 1;
} else {
+ UnMount(false);
+ Has_Android_Secure = false;
+ Symlink_Path = "";
+ Symlink_Mount_Point = "";
+ Backup_Name = Mount_Point.substr(1);
+ Backup_Path = Mount_Point;
+ TWPartition* sdext = PartitionManager.Find_Partition_By_Path("/sd-ext");
+ if (sdext && sdext->Actual_Block_Device == Adopted_Block_Device) {
+ LOGINFO("Removing /sd-ext from partition list due to adopted storage\n");
+ PartitionManager.Remove_Partition_By_Path("/sd-ext");
+ }
Setup_Data_Media();
Recreate_Media_Folder();
Wipe_Available_in_GUI = true;
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 1c59de7..cc090cf 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -2413,3 +2413,16 @@
return;
#endif
}
+
+void TWPartitionManager::Remove_Partition_By_Path(string Path) {
+ std::vector<TWPartition*>::iterator iter;
+ string Local_Path = TWFunc::Get_Root_Path(Path);
+
+ for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+ if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) {
+ LOGINFO("Found and erasing '%s' from partition list\n", Local_Path.c_str());
+ Partitions.erase(iter);
+ return;
+ }
+ }
+}
diff --git a/partitions.hpp b/partitions.hpp
index a020ee2..90f772c 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -243,7 +243,8 @@
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_Display_Names(); // Updates display names based on translations
- void Decrypt_Adopted();
+ 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
TWAtomicInt stop_backup;