Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bf3b71f authored by Daniel Zheng's avatar Daniel Zheng
Browse files

Updating Flashall to work off tasks

Test: testing fastboot flashall on raven
Bug: 194686221
Change-Id: I82ac2392686775b57c3d98ea003ab30b48f1ab0f
parent 85c0f3e5
Loading
Loading
Loading
Loading
+9 −17
Original line number Original line Diff line number Diff line
@@ -1588,11 +1588,6 @@ class FlashAllTool {
    void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images);
    void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images);
    void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf);
    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<const Image*, std::string>;

    std::vector<ImageEntry> boot_images_;
    std::vector<ImageEntry> boot_images_;
    std::vector<ImageEntry> os_images_;
    std::vector<ImageEntry> os_images_;
    FlashingPlan* fp_;
    FlashingPlan* fp_;
@@ -1621,15 +1616,15 @@ void FlashAllTool::Flash() {
    // or in bootloader fastboot.
    // or in bootloader fastboot.
    FlashImages(boot_images_);
    FlashImages(boot_images_);


    std::vector<std::unique_ptr<Task>> tasks;

    if (auto flash_super_task = FlashSuperLayoutTask::Initialize(fp_, os_images_)) {
    if (auto flash_super_task = FlashSuperLayoutTask::Initialize(fp_, os_images_)) {
        flash_super_task->Run();
        tasks.emplace_back(std::move(flash_super_task));
    } else {
    } else {
        // Sync the super partition. This will reboot to userspace fastboot if needed.
        // Sync the super partition. This will reboot to userspace fastboot if needed.
        std::unique_ptr<UpdateSuperTask> update_super_task = std::make_unique<UpdateSuperTask>(fp_);
        tasks.emplace_back(std::make_unique<UpdateSuperTask>(fp_));
        update_super_task->Run();
        // Resize any logical partition to 0, so each partition is reset to 0
        // Resize any logical partition to 0, so each partition is reset to 0
        // extents, and will achieve more optimal allocation.
        // extents, and will achieve more optimal allocation.
        std::vector<std::unique_ptr<ResizeTask>> resize_tasks;
        for (const auto& [image, slot] : os_images_) {
        for (const auto& [image, slot] : os_images_) {
            // Retrofit devices have two super partitions, named super_a and super_b.
            // Retrofit devices have two super partitions, named super_a and super_b.
            // On these devices, secondary slots must be flashed as physical
            // On these devices, secondary slots must be flashed as physical
@@ -1639,17 +1634,14 @@ void FlashAllTool::Flash() {
                std::string partition_name = image->part_name + "_"s + slot;
                std::string partition_name = image->part_name + "_"s + slot;
                if (image->IsSecondary() && is_logical(partition_name)) {
                if (image->IsSecondary() && is_logical(partition_name)) {
                    fp_->fb->DeletePartition(partition_name);
                    fp_->fb->DeletePartition(partition_name);
                    std::unique_ptr<DeleteTask> delete_task =
                            std::make_unique<DeleteTask>(fp_, partition_name);
                    delete_task->Run();
                }
                }
                tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
            }
            }
            resize_tasks.emplace_back(
            tasks.emplace_back(std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
                    std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
        }
        }
        for (auto& i : resize_tasks) {
            i->Run();
    }
    }
    for (auto& task : tasks) {
        task->Run();
    }
    }
    FlashImages(os_images_);
    FlashImages(os_images_);
}
}