mtp: don't create storage device after format data
Since we don't re-create data/media on FBE devices,
don't create an MTP storage device for it.
This fixes the bug when, after formatting data on
and FBE device, an empty Internal Storage appears
on the PC.
Change-Id: Iaafc5e3cde54c3ef6ffaf33f76d14c626b6e590d
diff --git a/partition.cpp b/partition.cpp
index 5bccd40..03eba4b 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -1749,10 +1749,7 @@
}
}
- if (Has_Data_Media && recreate_media) {
- Recreate_Media_Folder();
- }
- if (Is_Storage && Mount(false))
+ if (Is_Storage && Mount(false) && !Is_FBE)
PartitionManager.Add_MTP_Storage(MTP_Storage_ID);
}
@@ -2059,17 +2056,18 @@
Is_Encrypted = false;
if (Wipe(Fstab_File_System)) {
Has_Data_Media = Save_Data_Media;
- if (Has_Data_Media && !Symlink_Mount_Point.empty()) {
- Recreate_Media_Folder();
- if (Mount(false))
- PartitionManager.Add_MTP_Storage(MTP_Storage_ID);
- }
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
#ifndef TW_OEM_BUILD
gui_msg("format_data_msg=You may need to reboot recovery to be able to use /data again.");
#endif
if (Is_FBE) {
gui_msg(Msg(msg::kWarning, "data_media_fbe_msg=TWRP will not recreate /data/media on an FBE device. Please reboot into your rom to create /data/media."));
+ } else {
+ if (Has_Data_Media && !Symlink_Mount_Point.empty()) {
+ Recreate_Media_Folder();
+ if (Mount(false))
+ PartitionManager.Add_MTP_Storage(MTP_Storage_ID);
+ }
}
ret = true;