diff --git a/gui/action.cpp b/gui/action.cpp index 8aca45b0d..544db6d45 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -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); @@ -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"); diff --git a/gui/objects.hpp b/gui/objects.hpp index f0d8f08f8..2de2cf734 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -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 diff --git a/gui/theme/shrp_portrait_hdpi/languages/en.xml b/gui/theme/shrp_portrait_hdpi/languages/en.xml index bb8eea1bc..cbf9a7f2e 100644 --- a/gui/theme/shrp_portrait_hdpi/languages/en.xml +++ b/gui/theme/shrp_portrait_hdpi/languages/en.xml @@ -748,6 +748,10 @@ Pattern is enabled Pattern should be disabled before restore It is recommended to reboot Android once after first boot. + Merge Snapshots + Merge Snapshots? + Merging Snapshots... + Merged Snapshots None Enter Password diff --git a/partition.cpp b/partition.cpp index c33dada52..f7fe0013f 100755 --- a/partition.cpp +++ b/partition.cpp @@ -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; -} \ No newline at end of file diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 7446d9668..f26702dac 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -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(); @@ -3612,4 +3612,4 @@ bool TWPartitionManager::Check_Pending_Merges() { return false; } return true; -} +} \ No newline at end of file diff --git a/partitions.hpp b/partitions.hpp index b03b8fb7b..1b2f3cbf8 100755 --- a/partitions.hpp +++ b/partitions.hpp @@ -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 *twrp_flags); // Processes a fstab line @@ -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