diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 256aeefff..0979fd2f1 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1588,11 +1588,6 @@ class FlashAllTool { void FlashImages(const std::vector>& images); void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf); - // If the image uses the default slot, or the user specified "all", then - // the paired string will be empty. If the image requests a specific slot - // (for example, system_other) it is specified instead. - using ImageEntry = std::pair; - std::vector boot_images_; std::vector os_images_; FlashingPlan* fp_; @@ -1621,15 +1616,15 @@ void FlashAllTool::Flash() { // or in bootloader fastboot. FlashImages(boot_images_); + std::vector> tasks; + if (auto flash_super_task = FlashSuperLayoutTask::Initialize(fp_, os_images_)) { - flash_super_task->Run(); + tasks.emplace_back(std::move(flash_super_task)); } else { // Sync the super partition. This will reboot to userspace fastboot if needed. - std::unique_ptr update_super_task = std::make_unique(fp_); - update_super_task->Run(); + tasks.emplace_back(std::make_unique(fp_)); // Resize any logical partition to 0, so each partition is reset to 0 // extents, and will achieve more optimal allocation. - std::vector> resize_tasks; for (const auto& [image, slot] : os_images_) { // Retrofit devices have two super partitions, named super_a and super_b. // On these devices, secondary slots must be flashed as physical @@ -1639,18 +1634,15 @@ void FlashAllTool::Flash() { std::string partition_name = image->part_name + "_"s + slot; if (image->IsSecondary() && is_logical(partition_name)) { fp_->fb->DeletePartition(partition_name); - std::unique_ptr delete_task = - std::make_unique(fp_, partition_name); - delete_task->Run(); } + tasks.emplace_back(std::make_unique(fp_, partition_name)); } - resize_tasks.emplace_back( - std::make_unique(fp_, image->part_name, "0", slot)); - } - for (auto& i : resize_tasks) { - i->Run(); + tasks.emplace_back(std::make_unique(fp_, image->part_name, "0", slot)); } } + for (auto& task : tasks) { + task->Run(); + } FlashImages(os_images_); }