From cbda2c038b742915eb96e2cd469df6f804f2693a Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Tue, 18 Jul 2023 15:04:43 -0700 Subject: [PATCH] Adding flag to flash only static partitions adding in --exclude-dynamic-partitions to flash only bootloader partitions and skip the rest. Super optimization will be turned off as well when this flag is enabled Test: fastboot flashall --exclude-dynamic-partitions Change-Id: I4b9d70b7f6179bf079991bf3a20aade64cfe9935 --- fastboot/fastboot.cpp | 18 +++++++++++++++++- fastboot/fastboot.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 61c7204da..faee5e25d 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1794,6 +1794,7 @@ void FlashAllTool::Flash() { CancelSnapshotIfNeeded(); tasks_ = CollectTasks(); + for (auto& task : tasks_) { task->Run(); } @@ -1808,7 +1809,18 @@ std::vector> FlashAllTool::CollectTasks() { } else { tasks = CollectTasksFromImageList(); } - + if (fp_->exclude_dynamic_partitions) { + auto is_non_static_flash_task = [](const auto& task) -> bool { + if (auto flash_task = task->AsFlashTask()) { + if (!should_flash_in_userspace(flash_task->GetPartitionAndSlot())) { + return false; + } + } + return true; + }; + tasks.erase(std::remove_if(tasks.begin(), tasks.end(), is_non_static_flash_task), + tasks.end()); + } return tasks; } @@ -2213,6 +2225,7 @@ int FastBootTool::Main(int argc, char* argv[]) { {"disable-verification", no_argument, 0, 0}, {"disable-verity", no_argument, 0, 0}, {"disable-super-optimization", no_argument, 0, 0}, + {"exclude-dynamic-partitions", no_argument, 0, 0}, {"disable-fastboot-info", no_argument, 0, 0}, {"force", no_argument, 0, 0}, {"fs-options", required_argument, 0, 0}, @@ -2254,6 +2267,9 @@ int FastBootTool::Main(int argc, char* argv[]) { g_disable_verity = true; } else if (name == "disable-super-optimization") { fp->should_optimize_flash_super = false; + } else if (name == "exclude-dynamic-partitions") { + fp->exclude_dynamic_partitions = true; + fp->should_optimize_flash_super = false; } else if (name == "disable-fastboot-info") { fp->should_use_fastboot_info = false; } else if (name == "force") { diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h index f6ffb641f..3fb00e0fd 100644 --- a/fastboot/fastboot.h +++ b/fastboot/fastboot.h @@ -98,6 +98,7 @@ struct FlashingPlan { bool force_flash = false; bool should_optimize_flash_super = true; bool should_use_fastboot_info = true; + bool exclude_dynamic_partitions = false; uint64_t sparse_limit = 0; std::string slot_override;