Support alternative .android_secure location
Some devices (jewel, m8) have .android_secure at a non-standard
location. Allow a different partition to be specified as the home of
.android_secure using the fstab flag 'andsec'.
Using the /data/media variant of jewel as an example, recovery.fstab or
twrp.fstab could be edited like follows:
/external_sd vfat /dev/block/mmcblk1p1 flags=display="MicroSD";andsec
Note, this is NOT a method to move .android_secure in your ROM. Your ROM
must already write to this alternative location.
Change-Id: I3a6e4e63aaddb35870b79e80938b0f9c2c902443
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 495ef9b..d4e3715 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -57,6 +57,7 @@
FILE *fstabFile;
char fstab_line[MAX_FSTAB_LINE_LENGTH];
TWPartition* settings_partition = NULL;
+ TWPartition* andsec_partition = NULL;
fstabFile = fopen(Fstab_Filename.c_str(), "rt");
if (fstabFile == NULL) {
@@ -81,6 +82,11 @@
} else {
partition->Is_Settings_Storage = false;
}
+ if (!andsec_partition && partition->Has_Android_Secure) {
+ andsec_partition = partition;
+ } else {
+ partition->Has_Android_Secure = false;
+ }
Partitions.push_back(partition);
} else {
delete partition;
@@ -104,6 +110,11 @@
else
LOGINFO("Error creating fstab\n");
}
+ if (andsec_partition) {
+ Setup_Android_Secure_Location(andsec_partition);
+ } else {
+ Setup_Android_Secure_Location(settings_partition);
+ }
Setup_Settings_Storage_Partition(settings_partition);
Update_System_Details();
UnMount_Main_Partitions();
@@ -139,14 +150,20 @@
}
void TWPartitionManager::Setup_Settings_Storage_Partition(TWPartition* Part) {
-#ifndef RECOVERY_SDCARD_ON_DATA
- Part->Setup_AndSec();
-#endif
DataManager::SetValue("tw_settings_path", Part->Storage_Path);
DataManager::SetValue("tw_storage_path", Part->Storage_Path);
LOGINFO("Settings storage is '%s'\n", Part->Storage_Path.c_str());
}
+void TWPartitionManager::Setup_Android_Secure_Location(TWPartition* Part) {
+ if (Part->Has_Android_Secure)
+ Part->Setup_AndSec();
+#ifndef RECOVERY_SDCARD_ON_DATA
+ else
+ Part->Setup_AndSec();
+#endif
+}
+
void TWPartitionManager::Output_Partition_Logging(void) {
std::vector<TWPartition*>::iterator iter;