Added support for Delete Task
Test: tested delete-logical-partition {partition} and flashall on Raven Change-Id: I04f07c8132159deda42434b9178e8c98d5ab768b Bug: 194686221
This commit is contained in:
parent
9f7bf7eff3
commit
aa70f4c748
|
@ -1633,6 +1633,19 @@ void FlashAllTool::Flash() {
|
||||||
// extents, and will achieve more optimal allocation.
|
// extents, and will achieve more optimal allocation.
|
||||||
std::vector<std::unique_ptr<ResizeTask>> resize_tasks;
|
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.
|
||||||
|
// 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(
|
resize_tasks.emplace_back(
|
||||||
std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
|
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);
|
fb->CreatePartition(partition, size);
|
||||||
} else if (command == FB_CMD_DELETE_PARTITION) {
|
} else if (command == FB_CMD_DELETE_PARTITION) {
|
||||||
std::string partition = next_arg(&args);
|
std::string partition = next_arg(&args);
|
||||||
|
auto delete_task = std::make_unique<DeleteTask>(fp.get(), partition);
|
||||||
fb->DeletePartition(partition);
|
fb->DeletePartition(partition);
|
||||||
} 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);
|
||||||
|
|
|
@ -180,3 +180,9 @@ void ResizeTask::Run() {
|
||||||
};
|
};
|
||||||
do_for_partitions(pname_, slot_, resize_partition, false);
|
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_);
|
||||||
|
}
|
|
@ -92,3 +92,13 @@ class ResizeTask : public Task {
|
||||||
const std::string size_;
|
const std::string size_;
|
||||||
const std::string slot_;
|
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_;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue