diff options
Diffstat (limited to '')
-rw-r--r-- | partition.cpp | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/partition.cpp b/partition.cpp index f1d7fd2a9..00f84a128 100644 --- a/partition.cpp +++ b/partition.cpp @@ -73,6 +73,7 @@ extern "C" { using namespace std; extern struct selabel_handle *selinux_handle; +extern bool datamedia; struct flag_list { const char *name; @@ -160,6 +161,7 @@ TWPartition::TWPartition(int *id) { #ifdef TW_INCLUDE_CRYPTO_SAMSUNG EcryptFS_Password = ""; #endif + mtpid = 0; } TWPartition::~TWPartition(void) { @@ -272,27 +274,8 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { Can_Be_Backed_Up = true; Can_Encrypt_Backup = true; Use_Userdata_Encryption = true; -#ifdef RECOVERY_SDCARD_ON_DATA - Storage_Name = "Internal Storage"; - Has_Data_Media = true; - Is_Storage = true; - Is_Settings_Storage = true; - Storage_Path = "/data/media"; - Symlink_Path = Storage_Path; - if (strcmp(EXPAND(TW_EXTERNAL_STORAGE_PATH), "/sdcard") == 0) { - Make_Dir("/emmc", Display_Error); - Symlink_Mount_Point = "/emmc"; - } else { - Make_Dir("/sdcard", Display_Error); - Symlink_Mount_Point = "/sdcard"; - } - if (Mount(false) && TWFunc::Path_Exists("/data/media/0")) { - Storage_Path = "/data/media/0"; - Symlink_Path = Storage_Path; - DataManager::SetValue(TW_INTERNAL_PATH, "/data/media/0"); - UnMount(true); - } -#endif + if (datamedia) + Setup_Data_Media(0); #ifdef TW_INCLUDE_CRYPTO Can_Be_Encrypted = true; char crypto_blkdev[255]; @@ -343,14 +326,11 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { // unmounted state UnMount(false); } - #ifdef RECOVERY_SDCARD_ON_DATA - if (!Is_Encrypted || (Is_Encrypted && Is_Decrypted)) + if (datamedia && (!Is_Encrypted || (Is_Encrypted && Is_Decrypted))) Recreate_Media_Folder(); - #endif #else - #ifdef RECOVERY_SDCARD_ON_DATA - Recreate_Media_Folder(); - #endif + if (datamedia) + Recreate_Media_Folder(); #endif } else if (Mount_Point == "/cache") { Display_Name = "Cache"; @@ -702,6 +682,34 @@ void TWPartition::Setup_AndSec(void) { Mount_Storage_Retry(); } +void TWPartition::Setup_Data_Media(int mtp) { + LOGINFO("Setting up '%s' as data/media emulated storage.\n", Mount_Point.c_str()); + Storage_Name = "Internal Storage"; + Has_Data_Media = true; + Is_Storage = true; + Is_Settings_Storage = true; + Storage_Path = "/data/media"; + Symlink_Path = Storage_Path; + if (strcmp(EXPAND(TW_EXTERNAL_STORAGE_PATH), "/sdcard") == 0) { + Make_Dir("/emmc", false); + Symlink_Mount_Point = "/emmc"; + } else { + Make_Dir("/sdcard", false); + Symlink_Mount_Point = "/sdcard"; + } + if (Mount(false) && TWFunc::Path_Exists("/data/media/0")) { + Storage_Path = "/data/media/0"; + Symlink_Path = Storage_Path; + DataManager::SetValue(TW_INTERNAL_PATH, "/data/media/0"); + UnMount(true); + } + if (mtp) + mtpid = mtp; + DataManager::SetValue("tw_has_internal", 1); + DataManager::SetValue("tw_has_data_media", 1); + du.add_absolute_dir("/data/media"); +} + void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) { char device[512], realDevice[512]; |