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

Commit aa70f4c7 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

Added support for Delete Task

Test: tested delete-logical-partition {partition} and flashall on Raven

Change-Id: I04f07c8132159deda42434b9178e8c98d5ab768b
Bug: 194686221
parent 9f7bf7ef
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1633,6 +1633,19 @@ void FlashAllTool::Flash() {
        // extents, and will achieve more optimal allocation.
        std::vector<std::unique_ptr<ResizeTask>> 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
            // partitions (otherwise they would not mount on first boot). To enforce
            // this, we delete any logical partitions for the "other" slot.
            if (is_retrofit_device()) {
                std::string partition_name = image->part_name + "_"s + slot;
                if (image->IsSecondary() && is_logical(partition_name)) {
                    fp_->fb->DeletePartition(partition_name);
                    std::unique_ptr<DeleteTask> delete_task =
                            std::make_unique<DeleteTask>(fp_, partition_name);
                    delete_task->Run();
                }
            }
            resize_tasks.emplace_back(
                    std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
        }
@@ -2352,6 +2365,7 @@ int FastBootTool::Main(int argc, char* argv[]) {
            fb->CreatePartition(partition, size);
        } else if (command == FB_CMD_DELETE_PARTITION) {
            std::string partition = next_arg(&args);
            auto delete_task = std::make_unique<DeleteTask>(fp.get(), partition);
            fb->DeletePartition(partition);
        } else if (command == FB_CMD_RESIZE_PARTITION) {
            std::string partition = next_arg(&args);
+6 −0
Original line number Diff line number Diff line
@@ -180,3 +180,9 @@ void ResizeTask::Run() {
    };
    do_for_partitions(pname_, slot_, resize_partition, false);
}

DeleteTask::DeleteTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};

void DeleteTask::Run() {
    fp_->fb->DeletePartition(pname_);
}
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -92,3 +92,13 @@ class ResizeTask : public Task {
    const std::string size_;
    const std::string slot_;
};

class DeleteTask : public Task {
  public:
    DeleteTask(FlashingPlan* _fp, const std::string& _pname);
    void Run() override;

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