Loading fastboot/fastboot.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -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)); } Loading Loading @@ -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); Loading fastboot/task.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ using namespace std::string_literals; FlashTask::FlashTask(const std::string& _slot, const std::string& _pname) : pname_(_pname), fname_(find_item(_pname)), slot_(_slot) { FlashTask::FlashTask(const std::string& slot, const std::string& pname) : pname_(pname), fname_(find_item(pname)), slot_(slot) { if (fname_.empty()) die("cannot determine image filename for '%s'", pname_.c_str()); } FlashTask::FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname) Loading @@ -44,9 +44,9 @@ void FlashTask::Run() { do_for_partitions(pname_, slot_, flash, true); } RebootTask::RebootTask(FlashingPlan* _fp) : fp_(_fp){}; RebootTask::RebootTask(FlashingPlan* _fp, const std::string& _reboot_target) : reboot_target_(_reboot_target), fp_(_fp){}; RebootTask::RebootTask(FlashingPlan* fp) : fp_(fp){}; RebootTask::RebootTask(FlashingPlan* fp, const std::string& reboot_target) : reboot_target_(reboot_target), fp_(fp){}; void RebootTask::Run() { if ((reboot_target_ == "userspace" || reboot_target_ == "fastboot")) { Loading Loading @@ -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 fastboot/task.h +17 −9 Original line number Diff line number Diff line Loading @@ -32,11 +32,10 @@ class Task { class FlashTask : public Task { public: FlashTask(const std::string& _slot, const std::string& _pname); FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname); FlashTask(const std::string& slot, const std::string& pname); FlashTask(const std::string& slot, const std::string& pname, const std::string& fname); void Run() override; ~FlashTask() {} private: const std::string pname_; Loading @@ -46,14 +45,13 @@ class FlashTask : public Task { class RebootTask : public Task { public: RebootTask(FlashingPlan* _fp); RebootTask(FlashingPlan* _fp, const std::string& _reboot_target); RebootTask(FlashingPlan* fp); RebootTask(FlashingPlan* fp, const std::string& reboot_target); void Run() override; ~RebootTask() {} private: const std::string reboot_target_ = ""; FlashingPlan* fp_; const FlashingPlan* fp_; }; class FlashSuperLayoutTask : public Task { Loading @@ -77,7 +75,7 @@ class UpdateSuperTask : public Task { void Run() override; private: FlashingPlan* fp_; const FlashingPlan* fp_; }; class ResizeTask : public Task { Loading @@ -87,8 +85,18 @@ class ResizeTask : public Task { void Run() override; private: FlashingPlan* fp_; const FlashingPlan* fp_; const std::string pname_; const std::string size_; const std::string slot_; }; class DeleteTask : public Task { public: DeleteTask(FlashingPlan* _fp, const std::string& _pname); void Run() override; private: const FlashingPlan* fp_; const std::string pname_; }; Loading
fastboot/fastboot.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -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)); } Loading Loading @@ -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); Loading
fastboot/task.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ using namespace std::string_literals; FlashTask::FlashTask(const std::string& _slot, const std::string& _pname) : pname_(_pname), fname_(find_item(_pname)), slot_(_slot) { FlashTask::FlashTask(const std::string& slot, const std::string& pname) : pname_(pname), fname_(find_item(pname)), slot_(slot) { if (fname_.empty()) die("cannot determine image filename for '%s'", pname_.c_str()); } FlashTask::FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname) Loading @@ -44,9 +44,9 @@ void FlashTask::Run() { do_for_partitions(pname_, slot_, flash, true); } RebootTask::RebootTask(FlashingPlan* _fp) : fp_(_fp){}; RebootTask::RebootTask(FlashingPlan* _fp, const std::string& _reboot_target) : reboot_target_(_reboot_target), fp_(_fp){}; RebootTask::RebootTask(FlashingPlan* fp) : fp_(fp){}; RebootTask::RebootTask(FlashingPlan* fp, const std::string& reboot_target) : reboot_target_(reboot_target), fp_(fp){}; void RebootTask::Run() { if ((reboot_target_ == "userspace" || reboot_target_ == "fastboot")) { Loading Loading @@ -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
fastboot/task.h +17 −9 Original line number Diff line number Diff line Loading @@ -32,11 +32,10 @@ class Task { class FlashTask : public Task { public: FlashTask(const std::string& _slot, const std::string& _pname); FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname); FlashTask(const std::string& slot, const std::string& pname); FlashTask(const std::string& slot, const std::string& pname, const std::string& fname); void Run() override; ~FlashTask() {} private: const std::string pname_; Loading @@ -46,14 +45,13 @@ class FlashTask : public Task { class RebootTask : public Task { public: RebootTask(FlashingPlan* _fp); RebootTask(FlashingPlan* _fp, const std::string& _reboot_target); RebootTask(FlashingPlan* fp); RebootTask(FlashingPlan* fp, const std::string& reboot_target); void Run() override; ~RebootTask() {} private: const std::string reboot_target_ = ""; FlashingPlan* fp_; const FlashingPlan* fp_; }; class FlashSuperLayoutTask : public Task { Loading @@ -77,7 +75,7 @@ class UpdateSuperTask : public Task { void Run() override; private: FlashingPlan* fp_; const FlashingPlan* fp_; }; class ResizeTask : public Task { Loading @@ -87,8 +85,18 @@ class ResizeTask : public Task { void Run() override; private: FlashingPlan* fp_; const FlashingPlan* fp_; const std::string pname_; const std::string size_; const std::string slot_; }; class DeleteTask : public Task { public: DeleteTask(FlashingPlan* _fp, const std::string& _pname); void Run() override; private: const FlashingPlan* fp_; const std::string pname_; };