sdcard: only bind mount sdcard after successful preparation of data

Change-Id: I589f48a019f90a60ad48f93c5f5555aae4b8a5c9
This commit is contained in:
bigbiff
2022-02-08 00:52:07 +00:00
parent 2a8dc0dd8e
commit cda1588bc5
2 changed files with 23 additions and 10 deletions
+11 -6
View File
@@ -421,8 +421,12 @@ void TWPartitionManager::Decrypt_Data() {
TWPartition* Decrypt_Data = Find_Partition_By_Path("/data");
if (Decrypt_Data && Decrypt_Data->Is_Encrypted && !Decrypt_Data->Is_Decrypted) {
Set_Crypto_State();
if (!Decrypt_Data->Key_Directory.empty() && Mount_By_Path(Decrypt_Data->Key_Directory, false)) {
Set_Crypto_Type("file");
TWPartition* Key_Directory_Partition = Find_Partition_By_Path(Decrypt_Data->Key_Directory);
if (Key_Directory_Partition != nullptr)
if (!Key_Directory_Partition->Is_Mounted())
Mount_By_Path(Decrypt_Data->Key_Directory, false);
if (!Decrypt_Data->Key_Directory.empty()) {
Set_Crypto_Type("file");
#ifdef TW_INCLUDE_FBE_METADATA_DECRYPT
#ifdef USE_FSCRYPT
if (fscrypt_mount_metadata_encrypted(Decrypt_Data->Actual_Block_Device, Decrypt_Data->Mount_Point, false)) {
@@ -477,8 +481,7 @@ void TWPartitionManager::Decrypt_Data() {
}
}
}
if (Decrypt_Data && (!Decrypt_Data->Is_Encrypted || Decrypt_Data->Is_Decrypted) &&
Decrypt_Data->Mount(false)) {
if (Decrypt_Data && (!Decrypt_Data->Is_Encrypted || Decrypt_Data->Is_Decrypted)) {
Decrypt_Adopted();
}
#endif
@@ -1817,8 +1820,10 @@ void TWPartitionManager::Post_Decrypt(const string& Block_Device) {
DataManager::LoadTWRPFolderInfo();
Update_System_Details();
Output_Partition(dat);
if (!dat->Bind_Mount(false))
LOGERR("Unable to bind mount /sdcard to %s\n", dat->Storage_Path.c_str());
if (!android::base::StartsWith(dat->Actual_Block_Device, "/dev/block/mmcblk")) {
if (!dat->Bind_Mount(false))
LOGERR("Unable to bind mount /sdcard to %s\n", dat->Storage_Path.c_str());
}
} else
LOGERR("Unable to locate data partition.\n");
}