Flash both A/B partitions when flashing recovery ramdisk
Change-Id: Ib4017943be91f6b2030094d73daa826a4a1555d4
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 31e9098..f057389 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -3154,6 +3154,37 @@
}
DataManager::SetProgress(1);
TWFunc::removeDir(REPACK_ORIG_DIR, false);
+ if (part->SlotSelect && Repack_Options.Type == REPLACE_RAMDISK) {
+ LOGINFO("Switching slots to flash ramdisk to both partitions\n");
+ string Current_Slot = Get_Active_Slot_Display();
+ if (Current_Slot == "A")
+ Set_Active_Slot("B");
+ else
+ Set_Active_Slot("A");
+ DataManager::SetProgress(.25);
+ if (!PartitionManager.Prepare_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack")))
+ return false;
+ if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) {
+ LOGERR("Failed to copy ramdisk\n");
+ return false;
+ }
+ path = REPACK_ORIG_DIR;
+ command = "cd " + path + " && /sbin/magiskboot --repack " + path + "boot.img";
+ if (TWFunc::Exec_Cmd(command) != 0) {
+ gui_msg(Msg(msg::kError, "repack_error=Error repacking image."));
+ return false;
+ }
+ DataManager::SetProgress(.75);
+ std::string file = "new-boot.img";
+ DataManager::SetValue("tw_flash_partition", "/boot;");
+ if (!PartitionManager.Flash_Image(path, file)) {
+ LOGINFO("Error flashing new image\n");
+ return false;
+ }
+ DataManager::SetProgress(1);
+ TWFunc::removeDir(REPACK_ORIG_DIR, false);
+ Set_Active_Slot(Current_Slot);
+ }
TWFunc::removeDir(REPACK_NEW_DIR, false);
return true;
}