diff options
Diffstat (limited to 'partitionmanager.cpp')
-rwxr-xr-x | partitionmanager.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 31e909878..f0573890d 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -3154,6 +3154,37 @@ bool TWPartitionManager::Repack_Images(const std::string& Target_Image, const st } 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; } |