Skip to content

Commit

Permalink
pbrp: unified wipe modules
Browse files Browse the repository at this point in the history
for magisk and ksu

Signed-off-by: rezaadi0105 <[email protected]>
  • Loading branch information
rezaadi0105 committed Oct 5, 2023
1 parent 8a329f1 commit 7a5a7d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
10 changes: 5 additions & 5 deletions gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ int GUIAction::checkpartitionlist(std::string arg)
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" || part_path == "SUBSTRATUM" || part_path == "MAGISK") {
if (part_path == "/and-sec" || part_path == "DALVIK" || part_path == "INTERNAL" || part_path == "SUBSTRATUM" || part_path == "MODULE") {
// Do nothing
} else {
count++;
Expand Down Expand Up @@ -992,7 +992,7 @@ int GUIAction::getpartitiondetails(std::string arg)
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" || part_path == "SUBSTRATUM" || part_path == "MAGISK") {
if (part_path == "/and-sec" || part_path == "DALVIK" || part_path == "INTERNAL" || part_path == "SUBSTRATUM" || part_path == "MODULE") {
// Do nothing
} else {
DataManager::SetValue("tw_partition_path", part_path);
Expand Down Expand Up @@ -1412,9 +1412,9 @@ int GUIAction::wipe(std::string arg)
} else {
skip = true;
}
} else if (wipe_path == "MAGISK") {
if (!PartitionManager.Wipe_Magisk_Modules()) {
gui_err("pb_magisk_wipe_err=Failed to wipe magisk modules");
} else if (wipe_path == "MODULE") {
if (!PartitionManager.Wipe_Module()) {
gui_err("pb_module_wipe_err=Failed to wipe module");
ret_val = false;
break;
} else {
Expand Down
4 changes: 2 additions & 2 deletions gui/theme/common/languages/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@
<string name="substratum_done">-- Substratum Overlays Wipe Complete!</string>
<string name="show_free_sdmb">Show free SD card space in MB</string>
<string name="assert_failed_hint">An assert failed. Please check the output above for more details.</string>
<string name="pb_wipe_magisk_modules">Magisk Modules</string>
<string name="magisk_done">-- Magisk Modules Wipe Complete!</string>
<string name="pb_wipe_module">Module magisk-ksu</string>
<string name="module_done">-- Module Wipe Complete!</string>
<string name="pb_saving_log">Preserving Logs...</string>
<string name="pb_enable_logging">Copy Logs After Flash</string>
<string name="pb_enable_dmesg_logging">Include DMESG in Logs</string>
Expand Down
24 changes: 9 additions & 15 deletions partitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,20 +1599,14 @@ int TWPartitionManager::Wipe_Substratum_Overlays(void) {
return true;
}

int TWPartitionManager::Wipe_Magisk_Modules(void) {
string magisk_dir = "/data/adb/modules";
string magisk_dir2 = "/data/adb/post-fs-data.d";
string magisk_dir3 = "/data/adb/service.d";
int TWPartitionManager::Wipe_Module(void) {
string module_dir = "/data/adb";

if (!Mount_By_Path("/data", true)) return false;

if (TWFunc::Path_Exists(magisk_dir)) TWFunc::removeDir(magisk_dir, false);
if (TWFunc::Path_Exists(module_dir)) TWFunc::removeDir(module_dir, false);

if (TWFunc::Path_Exists(magisk_dir2)) TWFunc::removeDir(magisk_dir2, false);

if (TWFunc::Path_Exists(magisk_dir3)) TWFunc::removeDir(magisk_dir3, false);

gui_msg("magisk_done=-- Magisk Modules Wipe Complete!");
gui_msg("module_done=-- Module Wipe Complete!");
return true;
}

Expand Down Expand Up @@ -2729,11 +2723,11 @@ void TWPartitionManager::Get_Partition_List(string ListType,
substratum.Mount_Point = "SUBSTRATUM";
substratum.selected = 0;
Partition_List->push_back(substratum);
struct PartitionList magisk;
magisk.Display_Name = gui_parse_text("{@pb_wipe_magisk_modules}");
magisk.Mount_Point = "MAGISK";
magisk.selected = 0;
Partition_List->push_back(magisk);
struct PartitionList module;
module.Display_Name = gui_parse_text("{@pb_wipe_module}");
module.Mount_Point = "MODULE";
module.selected = 0;
Partition_List->push_back(module);
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Wipe_Available_in_GUI && !(*iter)->Is_SubPartition) {
struct PartitionList part;
Expand Down
2 changes: 1 addition & 1 deletion partitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class TWPartitionManager
int Factory_Reset(); // Performs a factory reset
int Wipe_Dalvik_Cache(); // Wipes dalvik cache
int Wipe_Substratum_Overlays(); // Wipe substratum overlays
int Wipe_Magisk_Modules(); // Wipe magisk modules
int Wipe_Module(); // Wipe modules magisk/ksu
int Wipe_Rotate_Data(); // Wipes rotation data --
int Wipe_Battery_Stats(); // Wipe battery stats -- /data/system/batterystats.bin
int Wipe_Android_Secure(); // Wipes android secure
Expand Down

0 comments on commit 7a5a7d5

Please sign in to comment.