merges: allow user to perform snapshot merges in advanced menu

Change-Id: I894a0ef5a0ec8e208053358f09a6b8a6d4ee408a
This commit is contained in:
bigbiff
2021-10-05 22:32:19 +00:00
parent 543a928359
commit d21252f1b5
9 changed files with 77 additions and 23 deletions
+10
View File
@@ -245,6 +245,7 @@ GUIAction::GUIAction(xml_node<>* node)
#ifndef TW_EXCLUDE_NANO
ADD_ACTION(editfile);
#endif
ADD_ACTION(mergesnapshots);
}
// First, get the action
@@ -2351,3 +2352,12 @@ int GUIAction::applycustomtwrpfolder(string arg __unused)
operation_end((int)!ret);
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;
}
+1
View File
@@ -378,6 +378,7 @@ protected:
int enablefastboot(std::string arg);
int changeterminal(std::string arg);
int applycustomtwrpfolder(std::string arg);
int mergesnapshots(std::string arg);
#ifndef TW_EXCLUDE_NANO
int editfile(std::string arg);
#endif
+11
View File
@@ -3813,6 +3813,17 @@
<action function="page">confirm_action</action>
</actions>
</listitem>
<listitem name="{@merges_snapshots=Merge Snapshots}">
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=mergesnapshots</action>
<action function="set">tw_text1={@merge_snapshots_confirm=Merge Snapshots?}</action>
<action function="set">tw_action_text1={@merging_snapshots=Merging Snapshots...}</action>
<action function="set">tw_complete_text1={@merging_snapshots_complete=Merged Snapshots}</action>
<action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
<action function="page">confirm_action</action>
</actions>
</listitem>
</listbox>
<action>
+4
View File
@@ -777,5 +777,9 @@
<string name="remove_dynamic_groups">Unmapping Super Devices...</string>
<string name="remove_dynamic_groups_complete">Unmapped all Super Devices</string>
<string name="mount_vab_partitions">Devices on super may not mount until rebooting recovery.</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>
</resources>
</language>
+11
View File
@@ -3935,6 +3935,17 @@
<action function="page">confirm_action</action>
</actions>
</listitem>
<listitem name="{@merges_snapshots=Merge Snapshots}">
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=mergesnapshots</action>
<action function="set">tw_text1={@merge_snapshots_confirm=Merge Snapshots?}</action>
<action function="set">tw_action_text1={@merging_snapshots=Merging Snapshots...}</action>
<action function="set">tw_complete_text1={@merging_snapshots_complete=Merged Snapshots}</action>
<action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
<action function="page">confirm_action</action>
</actions>
</listitem>
</listbox>
<action>
+11
View File
@@ -4414,6 +4414,17 @@
<action function="page">confirm_action</action>
</actions>
</listitem>
<listitem name="{@merges_snapshots=Merge Snapshots}">
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=mergesnapshots</action>
<action function="set">tw_text1={@merge_snapshots_confirm=Merge Snapshots?}</action>
<action function="set">tw_action_text1={@merging_snapshots=Merging Snapshots...}</action>
<action function="set">tw_complete_text1={@merging_snapshots_complete=Merged Snapshots}</action>
<action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
<action function="page">confirm_action</action>
</actions>
</listitem>
</listbox>
<button>
-21
View File
@@ -3463,24 +3463,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;
}
+28 -1
View File
@@ -1591,7 +1591,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();
@@ -3558,3 +3558,30 @@ bool TWPartitionManager::Unmap_Super_Devices() {
}
return true;
}
bool TWPartitionManager::Check_Pending_Merges() {
auto sm = android::snapshot::SnapshotManager::NewForFirstStageMount();
if (!sm) {
LOGERR("Unable to call snapshot manager\n");
return false;
}
if (!Unmap_Super_Devices()) {
LOGERR("Unable to unmap dynamic partitions.\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;
}
+1 -1
View File
@@ -178,7 +178,6 @@ protected:
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
@@ -404,6 +403,7 @@ public:
int Set_FDE_Encrypt_Status(); // Sets encryption state for FDE devices (ro.crypto.state and 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