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

Commit 28fbae67 authored by Daniel Zheng's avatar Daniel Zheng Committed by Automerger Merge Worker
Browse files

Merge "Added support for Resize Task" am: 62ee449d am: 4985bb71 am: d4517f95

parents 25f092a4 d4517f95
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -1631,13 +1631,13 @@ void FlashAllTool::Flash() {
        update_super_task->Run();
        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_) {
            auto resize_partition = [](const std::string& partition) -> void {
            resize_tasks.emplace_back(
                if (is_logical(partition)) {
                    std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
                    fb->ResizePartition(partition, "0");
        }
        }
            };
        for (auto& i : resize_tasks) {
            do_for_partitions(image->part_name, slot, resize_partition, false);
            i->Run();
        }
        }
    }
    }
    FlashImages(os_images_);
    FlashImages(os_images_);
@@ -2356,7 +2356,9 @@ int FastBootTool::Main(int argc, char* argv[]) {
        } else if (command == FB_CMD_RESIZE_PARTITION) {
        } else if (command == FB_CMD_RESIZE_PARTITION) {
            std::string partition = next_arg(&args);
            std::string partition = next_arg(&args);
            std::string size = next_arg(&args);
            std::string size = next_arg(&args);
            fb->ResizePartition(partition, size);
            std::unique_ptr<ResizeTask> resize_task =
                    std::make_unique<ResizeTask>(fp.get(), partition, size, slot_override);
            resize_task->Run();
        } else if (command == "gsi") {
        } else if (command == "gsi") {
            std::string arg = next_arg(&args);
            std::string arg = next_arg(&args);
            if (arg == "wipe") {
            if (arg == "wipe") {
+13 −0
Original line number Original line Diff line number Diff line
@@ -167,3 +167,16 @@ void UpdateSuperTask::Run() {
    }
    }
    fp_->fb->RawCommand(command, "Updating super partition");
    fp_->fb->RawCommand(command, "Updating super partition");
}
}

ResizeTask::ResizeTask(FlashingPlan* fp, const std::string& pname, const std::string& size,
                       const std::string& slot)
    : fp_(fp), pname_(pname), size_(size), slot_(slot) {}

void ResizeTask::Run() {
    auto resize_partition = [this](const std::string& partition) -> void {
        if (is_logical(partition)) {
            fp_->fb->ResizePartition(partition, size_);
        }
    };
    do_for_partitions(pname_, slot_, resize_partition, false);
}
+13 −0
Original line number Original line Diff line number Diff line
@@ -79,3 +79,16 @@ class UpdateSuperTask : public Task {
  private:
  private:
    FlashingPlan* fp_;
    FlashingPlan* fp_;
};
};

class ResizeTask : public Task {
  public:
    ResizeTask(FlashingPlan* fp, const std::string& pname, const std::string& size,
               const std::string& slot);
    void Run() override;

  private:
    FlashingPlan* fp_;
    const std::string pname_;
    const std::string size_;
    const std::string slot_;
};