Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
Flash both A/B partitions when flashing recovery ramdisk
Browse files Browse the repository at this point in the history
Change-Id: Ib4017943be91f6b2030094d73daa826a4a1555d4
  • Loading branch information
Dees-Troy committed May 16, 2019
1 parent 3cf05a5 commit 9f5dd31
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions partitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 9f5dd31

Please sign in to comment.