From 483e9f45b71458b84ccbbaf658449b58f029a63b Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 11 Jan 2016 22:21:18 -0600 Subject: 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 --- gui/action.cpp | 59 ++++++++++++++----------- gui/theme/common/landscape.xml | 87 ++++++++++++++++++++++++++++++++----- gui/theme/common/languages/en.xml | 1 + gui/theme/common/portrait.xml | 90 +++++++++++++++++++++++++++++++++----- gui/theme/common/watch.xml | 91 ++++++++++++++++++++++++++++++++++----- 5 files changed, 269 insertions(+), 59 deletions(-) (limited to 'gui') diff --git a/gui/action.cpp b/gui/action.cpp index 656c687b9..e13d15c68 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -792,25 +792,27 @@ int GUIAction::generatebackupname(std::string arg __unused) 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 @@ int GUIAction::checkpartitionlist(std::string arg __unused) 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 @@ int GUIAction::getpartitiondetails(std::string arg __unused) 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; } diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml index 6c91d0659..57fef4040 100755 --- a/gui/theme/common/landscape.xml +++ b/gui/theme/common/landscape.xml @@ -1068,7 +1068,7 @@ {@repair_change_btn=Repair or Change File System} - + tw_wipe_list checkpartitionlist @@ -1179,7 +1179,7 @@ partitionlisterror=0 - + tw_wipe_list partitionoptions @@ -1188,7 +1188,6 @@ partitionlisterror=1 - tw_wipe_list= advancedwipe @@ -1271,6 +1270,7 @@ tw_action_param=%tw_partition_mount_point% tw_has_action2=1 tw_action2=getpartitiondetails + tw_action2_param=tw_wipe_list tw_text1={@resize_confirm=Resize %tw_partition_name%?} tw_text2= tw_action_text1={@resizing=Resizing...} @@ -1320,7 +1320,7 @@ partitionlisterror=0 - + tw_wipe_list selectfilesystem @@ -3091,7 +3091,10 @@ {@part_sd_btn=Partition SD Card} - partsdcard + + partitionlisterror=0 + partsdcardsel +