merges: allow user to perform snapshot merges in advanced menu
Change-Id: I894a0ef5a0ec8e208053358f09a6b8a6d4ee408a
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 481d8d8..285b92a 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1591,7 +1591,7 @@
#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 @@
}
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;
+}
\ No newline at end of file