diff --git a/partition.cpp b/partition.cpp index a8a8e459..be01b159 100755 --- a/partition.cpp +++ b/partition.cpp @@ -462,6 +462,20 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, Wipe_Available_in_GUI = true; Can_Be_Backed_Up = true; Mount_Read_Only = true; + } else if (Mount_Point == "/product") { + Display_Name = "Product"; + Backup_Name = "Product"; + Backup_Display_Name = Display_Name; + Storage_Name = Display_Name; + Can_Be_Backed_Up = Wipe_Available_in_GUI = Is_Super ? false : true; + Mount_Read_Only = true; + } else if (Mount_Point == "/odm") { + Display_Name = "ODM"; + Backup_Name = "ODM"; + Backup_Display_Name = Display_Name; + Storage_Name = Display_Name; + Can_Be_Backed_Up = Wipe_Available_in_GUI = Is_Super ? false : true; + Mount_Read_Only = true; } else if (Mount_Point == "/data") { Display_Name = "Data"; Backup_Display_Name = Display_Name; diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 7cc126f4..b19742e0 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -248,6 +248,9 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, mapit->second.fstab_line = NULL; } } + if (Get_Super_Status()) { + Setup_Super_Devices(); + } LOGINFO("Done processing fstab files\n"); std::vector::iterator iter; @@ -275,6 +278,27 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, andsec_partition = (*iter); else (*iter)->Has_Android_Secure = false; + if (Is_Super_Partition(TWFunc::Remove_Beginning_Slash((*iter)->Get_Mount_Point()).c_str())) + Prepare_Super_Volume((*iter)); + } + + //Setup Apex before decryption + TWPartition* sys = PartitionManager.Find_Partition_By_Path(PartitionManager.Get_Android_Root_Path()); + TWPartition* ven = PartitionManager.Find_Partition_By_Path("/vendor"); + if (sys) { + if (sys->Get_Super_Status()) { + sys->Mount(true); + if (ven) { + ven->Mount(true); + } + twrpApex apex; + if (!apex.loadApexImages()) { + LOGERR("Unable to load apex images from %s\n", APEX_DIR); + property_set("twrp.apex.loaded", "false"); + } else { + property_set("twrp.apex.loaded", "true"); + } + } } if (!datamedia && !settings_partition && Find_Partition_By_Path("/sdcard") == NULL && Find_Partition_By_Path("/internal_sd") == NULL && Find_Partition_By_Path("/internal_sdcard") == NULL && Find_Partition_By_Path("/emmc") == NULL) { @@ -316,7 +340,14 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, Setup_Settings_Storage_Partition(settings_partition); } +#ifdef TW_INCLUDE_CRYPTO + DataManager::SetValue(TW_IS_ENCRYPTED, 1); + Decrypt_Data(); +#endif + Update_System_Details(); + if (Get_Super_Status()) + Setup_Super_Partition(); UnMount_Main_Partitions(); #ifdef AB_OTA_UPDATER DataManager::SetValue("tw_active_slot", Get_Active_Slot_Display()); @@ -361,7 +392,8 @@ void TWPartitionManager::Decrypt_Data() { #ifdef TW_INCLUDE_FBE_METADATA_DECRYPT #ifdef USE_FSCRYPT if (fscrypt_mount_metadata_encrypted(Decrypt_Data->Actual_Block_Device, Decrypt_Data->Mount_Point, false)) { - std::string crypto_blkdev = android::base::GetProperty("ro.crypto.fs_crypto_blkdev", "error"); + std::string crypto_blkdev =android::base::GetProperty("ro.crypto.fs_crypto_blkdev", "error"); + Decrypt_Data->Decrypted_Block_Device = crypto_blkdev; LOGINFO("Successfully decrypted metadata encrypted data partition with new block device: '%s'\n", crypto_blkdev.c_str()); #else if (e4crypt_mount_metadata_encrypted(Decrypt_Data->Mount_Point, false, Decrypt_Data->Key_Directory, Decrypt_Data->Actual_Block_Device, &Decrypt_Data->Decrypted_Block_Device)) { @@ -1989,14 +2021,18 @@ void TWPartitionManager::UnMount_Main_Partitions(void) { // Also unmounts boot if boot is mountable LOGINFO("Unmounting main partitions...\n"); - TWPartition* Boot_Partition = Find_Partition_By_Path("/boot"); + TWPartition *Partition = Find_Partition_By_Path ("/vendor"); - UnMount_By_Path(Get_Android_Root_Path(), true); + if (Partition != NULL) UnMount_By_Path("/vendor", false); + UnMount_By_Path (Get_Android_Root_Path(), true); + Partition = Find_Partition_By_Path ("/product"); + if (Partition != NULL) UnMount_By_Path("/product", false); if (!datamedia) UnMount_By_Path("/data", true); - if (Boot_Partition != NULL && Boot_Partition->Can_Be_Mounted) - Boot_Partition->UnMount(true); + Partition = Find_Partition_By_Path ("/boot"); + if (Partition != NULL && Partition->Can_Be_Mounted) + Partition->UnMount(true); } int TWPartitionManager::Partition_SDCard(void) { @@ -3170,6 +3206,8 @@ bool TWPartitionManager::Prepare_All_Super_Volumes() { } bool TWPartitionManager::Is_Super_Partition(const char* fstab_line) { + if (!Get_Super_Status()) + return false; std::vector super_partition_list = {"system", "vendor", "odm", "product", "system_ext"}; for (auto&& fstab_partition_check: super_partition_list) { diff --git a/partitions.hpp b/partitions.hpp index 55a0ac17..be8dcd70 100755 --- a/partitions.hpp +++ b/partitions.hpp @@ -27,6 +27,7 @@ #include "tw_atomic.hpp" #include "progresstracking.hpp" #include "fscrypt_policy.h" +#include "twrpApex.hpp" #define MAX_FSTAB_LINE_LENGTH 2048 diff --git a/twrp.cpp b/twrp.cpp index a187486b..0d9326dc 100755 --- a/twrp.cpp +++ b/twrp.cpp @@ -51,7 +51,6 @@ extern "C" { #include "openrecoveryscript.hpp" #include "variables.h" #include "twrpAdbBuFifo.hpp" -#include "twrpApex.hpp" #ifdef TW_USE_NEW_MINADBD // #include "minadbd/minadbd.h" #else @@ -77,6 +76,8 @@ static void Decrypt_Page(bool SkipDecryption, bool datamedia) { LOGINFO("Skipping decryption\n"); } else { LOGINFO("Is encrypted, do decrypt page first\n"); + if (DataManager::GetIntValue(TW_IS_FBE)) + DataManager::SetValue("tw_crypto_user_id", "0"); if (gui_startPage("decrypt", 1, 1) != 0) { LOGERR("Failed to start decrypt GUI page.\n"); } else { @@ -197,19 +198,6 @@ int main(int argc, char **argv) { return -1; } PartitionManager.Output_Partition_Logging(); -#ifdef TW_INCLUDE_CRYPTO - DataManager::SetValue(TW_IS_ENCRYPTED, 1); -#endif - - if (PartitionManager.Get_Super_Status()) { - PartitionManager.Setup_Super_Devices(); - PartitionManager.Setup_Super_Partition(); - } else { -#ifdef TW_INCLUDE_CRYPTO - if (!PartitionManager.Get_Super_Status()) - PartitionManager.Decrypt_Data(); -#endif - } // Load up all the resources gui_loadResources(); @@ -318,8 +306,7 @@ int main(int argc, char **argv) { LOGINFO("Backup of TWRP ramdisk done.\n"); #endif - if (!PartitionManager.Get_Super_Status()) - Decrypt_Page(SkipDecryption, datamedia); + Decrypt_Page(SkipDecryption, datamedia); // Fixup the RTC clock on devices which require it if (crash_counter == 0) @@ -368,21 +355,7 @@ int main(int argc, char **argv) { TWPartition* ven = PartitionManager.Find_Partition_By_Path("/vendor"); if (sys) { if (sys->Get_Super_Status()) { - if (!PartitionManager.Prepare_All_Super_Volumes()) { - LOGERR("Unable to prepare super volumes.\n"); - } - sys->Mount(true); - if (ven) { - ven->Mount(true); - } - twrpApex apex; - if (!apex.loadApexImages()) { - LOGERR("Unable to load apex images from %s\n", APEX_DIR); - } - property_set("twrp.apex.loaded", "true"); #ifdef TW_INCLUDE_CRYPTO - PartitionManager.Decrypt_Data(); - Decrypt_Page(SkipDecryption, datamedia); std::string recoveryLogDir(DATA_LOGS_DIR); recoveryLogDir += "/recovery"; if (!TWFunc::Path_Exists(recoveryLogDir)) {