Loading fastboot/fastboot.cpp +8 −13 Original line number Diff line number Diff line Loading @@ -1830,7 +1830,7 @@ static unsigned fb_get_flash_block_size(std::string name) { return size; } static void fb_perform_format(const std::string& partition, int skip_if_not_supported, void fb_perform_format(const std::string& partition, int skip_if_not_supported, const std::string& type_override, const std::string& size_override, const unsigned fs_options) { std::string partition_type, partition_size; Loading Loading @@ -2026,7 +2026,6 @@ int FastBootTool::Main(int argc, char* argv[]) { android::base::InitLogging(argv, FastbootLogger, FastbootAborter); std::unique_ptr<FlashingPlan> fp = std::make_unique<FlashingPlan>(); unsigned fs_options = 0; int longindex; std::string slot_override; std::string next_active; Loading Loading @@ -2080,7 +2079,7 @@ int FastBootTool::Main(int argc, char* argv[]) { } else if (name == "force") { fp->force_flash = true; } else if (name == "fs-options") { fs_options = ParseFsOption(optarg); fp->fs_options = ParseFsOption(optarg); } else if (name == "header-version") { g_boot_img_hdr.header_version = strtoul(optarg, nullptr, 0); } else if (name == "dtb") { Loading Loading @@ -2250,7 +2249,7 @@ int FastBootTool::Main(int argc, char* argv[]) { std::string partition = next_arg(&args); auto format = [&](const std::string& partition) { fb_perform_format(partition, 0, type_override, size_override, fs_options); fb_perform_format(partition, 0, type_override, size_override, fp->fs_options); }; do_for_partitions(partition, slot_override, format, true); } else if (command == "signature") { Loading Loading @@ -2407,19 +2406,15 @@ int FastBootTool::Main(int argc, char* argv[]) { syntax_error("unknown command %s", command.c_str()); } } if (fp->wants_wipe) { if (fp->force_flash) { CancelSnapshotIfNeeded(); } std::vector<std::string> partitions = {"userdata", "cache", "metadata"}; for (const auto& partition : partitions) { std::string partition_type; if (fb->GetVar("partition-type:" + partition, &partition_type) != fastboot::SUCCESS) { continue; } if (partition_type.empty()) continue; fb->Erase(partition); fb_perform_format(partition, 1, partition_type, "", fs_options); std::unique_ptr<WipeTask> wipe_task = std::make_unique<WipeTask>(fp.get(), partition); wipe_task->Run(); } } if (fp->wants_set_active) { Loading fastboot/fastboot.h +4 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ struct Image { using ImageEntry = std::pair<const Image*, std::string>; struct FlashingPlan { unsigned fs_options = 0; // 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. Loading Loading @@ -109,3 +110,6 @@ std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size); bool is_retrofit_device(); bool is_logical(const std::string& partition); void fb_perform_format(const std::string& partition, int skip_if_not_supported, const std::string& type_override, const std::string& size_override, const unsigned fs_options); fastboot/task.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -143,8 +143,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( return std::make_unique<FlashSuperLayoutTask>(super_name, std::move(helper), std::move(s)); } UpdateSuperTask::UpdateSuperTask(FlashingPlan* fp) : fp_(fp) {} UpdateSuperTask::UpdateSuperTask(FlashingPlan* fp) : fp_(fp) {} void UpdateSuperTask::Run() { unique_fd fd = fp_->source->OpenFile("super_empty.img"); Loading Loading @@ -186,3 +185,15 @@ DeleteTask::DeleteTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pn void DeleteTask::Run() { fp_->fb->DeletePartition(pname_); } WipeTask::WipeTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){}; void WipeTask::Run() { std::string partition_type; if (fp_->fb->GetVar("partition-type:" + pname_, &partition_type) != fastboot::SUCCESS) { return; } if (partition_type.empty()) return; fp_->fb->Erase(pname_); fb_perform_format(pname_, 1, partition_type, "", fp_->fs_options); } fastboot/task.h +10 −0 Original line number Diff line number Diff line Loading @@ -100,3 +100,13 @@ class DeleteTask : public Task { const FlashingPlan* fp_; const std::string pname_; }; class WipeTask : public Task { public: WipeTask(FlashingPlan* fp, const std::string& pname); void Run() override; private: const FlashingPlan* fp_; const std::string pname_; }; Loading
fastboot/fastboot.cpp +8 −13 Original line number Diff line number Diff line Loading @@ -1830,7 +1830,7 @@ static unsigned fb_get_flash_block_size(std::string name) { return size; } static void fb_perform_format(const std::string& partition, int skip_if_not_supported, void fb_perform_format(const std::string& partition, int skip_if_not_supported, const std::string& type_override, const std::string& size_override, const unsigned fs_options) { std::string partition_type, partition_size; Loading Loading @@ -2026,7 +2026,6 @@ int FastBootTool::Main(int argc, char* argv[]) { android::base::InitLogging(argv, FastbootLogger, FastbootAborter); std::unique_ptr<FlashingPlan> fp = std::make_unique<FlashingPlan>(); unsigned fs_options = 0; int longindex; std::string slot_override; std::string next_active; Loading Loading @@ -2080,7 +2079,7 @@ int FastBootTool::Main(int argc, char* argv[]) { } else if (name == "force") { fp->force_flash = true; } else if (name == "fs-options") { fs_options = ParseFsOption(optarg); fp->fs_options = ParseFsOption(optarg); } else if (name == "header-version") { g_boot_img_hdr.header_version = strtoul(optarg, nullptr, 0); } else if (name == "dtb") { Loading Loading @@ -2250,7 +2249,7 @@ int FastBootTool::Main(int argc, char* argv[]) { std::string partition = next_arg(&args); auto format = [&](const std::string& partition) { fb_perform_format(partition, 0, type_override, size_override, fs_options); fb_perform_format(partition, 0, type_override, size_override, fp->fs_options); }; do_for_partitions(partition, slot_override, format, true); } else if (command == "signature") { Loading Loading @@ -2407,19 +2406,15 @@ int FastBootTool::Main(int argc, char* argv[]) { syntax_error("unknown command %s", command.c_str()); } } if (fp->wants_wipe) { if (fp->force_flash) { CancelSnapshotIfNeeded(); } std::vector<std::string> partitions = {"userdata", "cache", "metadata"}; for (const auto& partition : partitions) { std::string partition_type; if (fb->GetVar("partition-type:" + partition, &partition_type) != fastboot::SUCCESS) { continue; } if (partition_type.empty()) continue; fb->Erase(partition); fb_perform_format(partition, 1, partition_type, "", fs_options); std::unique_ptr<WipeTask> wipe_task = std::make_unique<WipeTask>(fp.get(), partition); wipe_task->Run(); } } if (fp->wants_set_active) { Loading
fastboot/fastboot.h +4 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ struct Image { using ImageEntry = std::pair<const Image*, std::string>; struct FlashingPlan { unsigned fs_options = 0; // 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. Loading Loading @@ -109,3 +110,6 @@ std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size); bool is_retrofit_device(); bool is_logical(const std::string& partition); void fb_perform_format(const std::string& partition, int skip_if_not_supported, const std::string& type_override, const std::string& size_override, const unsigned fs_options);
fastboot/task.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -143,8 +143,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( return std::make_unique<FlashSuperLayoutTask>(super_name, std::move(helper), std::move(s)); } UpdateSuperTask::UpdateSuperTask(FlashingPlan* fp) : fp_(fp) {} UpdateSuperTask::UpdateSuperTask(FlashingPlan* fp) : fp_(fp) {} void UpdateSuperTask::Run() { unique_fd fd = fp_->source->OpenFile("super_empty.img"); Loading Loading @@ -186,3 +185,15 @@ DeleteTask::DeleteTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pn void DeleteTask::Run() { fp_->fb->DeletePartition(pname_); } WipeTask::WipeTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){}; void WipeTask::Run() { std::string partition_type; if (fp_->fb->GetVar("partition-type:" + pname_, &partition_type) != fastboot::SUCCESS) { return; } if (partition_type.empty()) return; fp_->fb->Erase(pname_); fb_perform_format(pname_, 1, partition_type, "", fp_->fs_options); }
fastboot/task.h +10 −0 Original line number Diff line number Diff line Loading @@ -100,3 +100,13 @@ class DeleteTask : public Task { const FlashingPlan* fp_; const std::string pname_; }; class WipeTask : public Task { public: WipeTask(FlashingPlan* fp, const std::string& pname); void Run() override; private: const FlashingPlan* fp_; const std::string pname_; };