Skip to content

Commit

Permalink
merges: allow user to perform snapshot merges in advanced menu
Browse files Browse the repository at this point in the history
Change-Id: I894a0ef5a0ec8e208053358f09a6b8a6d4ee408a
  • Loading branch information
epicX67 committed Nov 14, 2021
1 parent 2da4960 commit 04d899b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
9 changes: 9 additions & 0 deletions gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ GUIAction::GUIAction(xml_node<>* node)
#ifndef TW_EXCLUDE_NANO
ADD_ACTION(editfile);
#endif
ADD_ACTION(mergesnapshots);

ADD_ACTION(shrp_init);
ADD_ACTION(shrp_magisk_info);
Expand Down Expand Up @@ -2453,6 +2454,14 @@ int GUIAction::applycustomtwrpfolder(string arg __unused)
return 0;
}

int GUIAction::mergesnapshots(string arg __unused) {
int op_status = 1;
if (PartitionManager.Check_Pending_Merges()) {
op_status = 0;
}
operation_end(op_status);
return 0;
}
//SHRP_GUI_Funcs()
int GUIAction::shrp_init(std::string arg __unused){
LOGINFO("Running GUI function : shrp_init\n");
Expand Down
1 change: 1 addition & 0 deletions gui/objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ class GUIAction : public GUIObject, public ActionObject
int enableadb(std::string arg);
int enablefastboot(std::string arg);
int changeterminal(std::string arg);
int mergesnapshots(std::string arg);
#ifndef TW_EXCLUDE_NANO
int editfile(std::string arg);
#endif
Expand Down
4 changes: 4 additions & 0 deletions gui/theme/shrp_portrait_hdpi/languages/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@
<string name="restore_with_pattern1">Pattern is enabled</string>
<string name="restore_with_pattern2">Pattern should be disabled before restore</string>
<string name="reboot_after_restore">It is recommended to reboot Android once after first boot.</string>
<string name="merges_snapshots">Merge Snapshots</string>
<string name="merge_snapshots_confirm">Merge Snapshots?</string>
<string name="merging_snapshots">Merging Snapshots...</string>
<string name="merging_snapshots_complete">Merged Snapshots</string>
<!--Change All The strings from here-->
<string name="Tcredit">None</string>
<string name="c_enter_pass">Enter Password</string>
Expand Down
21 changes: 0 additions & 21 deletions partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3467,24 +3467,3 @@ std::string TWPartition::Get_Display_Name() {
bool TWPartition::Is_SlotSelect() {
return SlotSelect;
}

bool TWPartition::Check_Pending_Merges() {
auto sm = android::snapshot::SnapshotManager::NewForFirstStageMount();
if (!sm) {
LOGERR("Unable to call snapshot manager\n");
return false;
}

auto callback = [&]() -> void {
double progress;
sm->GetUpdateState(&progress);
LOGINFO("waiting for merge to complete: %.2f\n", progress);
};

LOGINFO("checking for merges\n");
if (!sm->HandleImminentDataWipe(callback)) {
LOGERR("Unable to check merge status\n");
return false;
}
return true;
}
4 changes: 2 additions & 2 deletions partitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ int TWPartitionManager::Format_Data(void) {
#endif
if (metadata != NULL)
metadata->Mount(true);
if (!dat->Check_Pending_Merges())
if (!Check_Pending_Merges())
return false;
}
return dat->Wipe_Encryption();
Expand Down Expand Up @@ -3612,4 +3612,4 @@ bool TWPartitionManager::Check_Pending_Merges() {
return false;
}
return true;
}
}
2 changes: 1 addition & 1 deletion partitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class TWPartition
bool Has_Data_Media; // Indicates presence of /data/media, may affect wiping and backup methods
void Setup_Data_Media(); // Sets up a partition as a /data/media emulated storage partition
void Set_Block_Device(std::string block_device); // Allow super partition setup to change block device
bool Check_Pending_Merges(); // Check and run pending merges on data for VAB devices

private:
bool Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags); // Processes a fstab line
Expand Down Expand Up @@ -405,6 +404,7 @@ class TWPartitionManager
int Set_Crypto_Type(const char* crypto_type); // Sets encryption type for FDE (block) and FBE (file) devices (ro.crypto.type)
void Unlock_Block_Partitions(); // Unlock all block devices after update_engine runs
bool Unmap_Super_Devices(); // Unmap super devices in TWRP
bool Check_Pending_Merges(); // Check and run pending merges on data for VAB devices

private:
void Setup_Settings_Storage_Partition(TWPartition* Part); // Sets up settings storage
Expand Down

0 comments on commit 04d899b

Please sign in to comment.