Improve sdcard partitioning process
-Improve code for partitioning sdcards
-Allow user to select a device for partitioning (must be removable)
-Use sgdisk to partition sdcards
-Set default sizes for ext and swap to 0
-Change increments for ext to 256MB and swap to 64MB
Note: sgdisk is included in 6.0. I have included a static prebuilt
sgdisk for trees that do not have sgdisk, however the prebuilt
sgdisk is a decent bit larger than the old parted binary. The old
parted binary is quite old at this point and we only have it for
armv7a. sgdisk should be maintained by AOSP and can be built from
source so it should work across architectures.
Change-Id: Ib80882d9b5776e5e9358b11340fba392e6f1ae09
diff --git a/gui/action.cpp b/gui/action.cpp
index 656c687..e13d15c 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -792,25 +792,27 @@
return 0;
}
-int GUIAction::checkpartitionlist(std::string arg __unused)
+int GUIAction::checkpartitionlist(std::string arg)
{
- string Wipe_List, wipe_path;
+ string List, part_path;
int count = 0;
- DataManager::GetValue("tw_wipe_list", Wipe_List);
- LOGINFO("checkpartitionlist list '%s'\n", Wipe_List.c_str());
- if (!Wipe_List.empty()) {
- size_t start_pos = 0, end_pos = Wipe_List.find(";", start_pos);
- while (end_pos != string::npos && start_pos < Wipe_List.size()) {
- wipe_path = Wipe_List.substr(start_pos, end_pos - start_pos);
- LOGINFO("checkpartitionlist wipe_path '%s'\n", wipe_path.c_str());
- if (wipe_path == "/and-sec" || wipe_path == "DALVIK" || wipe_path == "INTERNAL") {
+ if (arg.empty())
+ arg = "tw_wipe_list";
+ DataManager::GetValue(arg, List);
+ LOGINFO("checkpartitionlist list '%s'\n", List.c_str());
+ if (!List.empty()) {
+ size_t start_pos = 0, end_pos = List.find(";", start_pos);
+ while (end_pos != string::npos && start_pos < List.size()) {
+ part_path = List.substr(start_pos, end_pos - start_pos);
+ LOGINFO("checkpartitionlist part_path '%s'\n", part_path.c_str());
+ if (part_path == "/and-sec" || part_path == "DALVIK" || part_path == "INTERNAL") {
// Do nothing
} else {
count++;
}
start_pos = end_pos + 1;
- end_pos = Wipe_List.find(";", start_pos);
+ end_pos = List.find(";", start_pos);
}
DataManager::SetValue("tw_check_partition_list", count);
} else {
@@ -819,29 +821,32 @@
return 0;
}
-int GUIAction::getpartitiondetails(std::string arg __unused)
+int GUIAction::getpartitiondetails(std::string arg)
{
- string Wipe_List, wipe_path;
+ string List, part_path;
int count = 0;
- DataManager::GetValue("tw_wipe_list", Wipe_List);
- LOGINFO("getpartitiondetails list '%s'\n", Wipe_List.c_str());
- if (!Wipe_List.empty()) {
- size_t start_pos = 0, end_pos = Wipe_List.find(";", start_pos);
- while (end_pos != string::npos && start_pos < Wipe_List.size()) {
- wipe_path = Wipe_List.substr(start_pos, end_pos - start_pos);
- LOGINFO("getpartitiondetails wipe_path '%s'\n", wipe_path.c_str());
- if (wipe_path == "/and-sec" || wipe_path == "DALVIK" || wipe_path == "INTERNAL") {
+ if (arg.empty())
+ arg = "tw_wipe_list";
+ DataManager::GetValue(arg, List);
+ LOGINFO("getpartitiondetails list '%s'\n", List.c_str());
+ if (!List.empty()) {
+ size_t start_pos = 0, end_pos = List.find(";", start_pos);
+ part_path = List;
+ while (end_pos != string::npos && start_pos < List.size()) {
+ part_path = List.substr(start_pos, end_pos - start_pos);
+ LOGINFO("getpartitiondetails part_path '%s'\n", part_path.c_str());
+ if (part_path == "/and-sec" || part_path == "DALVIK" || part_path == "INTERNAL") {
// Do nothing
} else {
- DataManager::SetValue("tw_partition_path", wipe_path);
+ DataManager::SetValue("tw_partition_path", part_path);
break;
}
start_pos = end_pos + 1;
- end_pos = Wipe_List.find(";", start_pos);
+ end_pos = List.find(";", start_pos);
}
- if (!wipe_path.empty()) {
- TWPartition* Part = PartitionManager.Find_Partition_By_Path(wipe_path);
+ if (!part_path.empty()) {
+ TWPartition* Part = PartitionManager.Find_Partition_By_Path(part_path);
if (Part) {
unsigned long long mb = 1048576;
@@ -881,12 +886,14 @@
DataManager::SetValue("tw_partition_ext", 0);
return 0;
} else {
- LOGERR("Unable to locate partition: '%s'\n", wipe_path.c_str());
+ LOGERR("Unable to locate partition: '%s'\n", part_path.c_str());
}
}
}
DataManager::SetValue("tw_partition_name", "");
DataManager::SetValue("tw_partition_file_system", "");
+ // Set this to 0 to prevent trying to partition this device, just in case
+ DataManager::SetValue("tw_partition_removable", 0);
return 0;
}