From d62002cf06cd01b687d192095eb1514130095fc0 Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Wed, 21 Jun 2023 14:27:35 -0700 Subject: [PATCH] Add flag to disable super optimization Adding flag to turn off the super optimization. Makes for easier testing as dynamic partitions flash tasks won't be replaced by one flash super layout task Test: fastboot flashall --disable-super-optimization Bug: 194686221 Change-Id: I9142490ecfe587725872e4b734486d3db1728aa7 --- fastboot/fastboot.cpp | 3 +++ fastboot/fastboot.h | 1 + fastboot/task.cpp | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index faaca1d69..42d4f60d0 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -2191,6 +2191,7 @@ int FastBootTool::Main(int argc, char* argv[]) { {"cmdline", required_argument, 0, 0}, {"disable-verification", no_argument, 0, 0}, {"disable-verity", no_argument, 0, 0}, + {"disable-super-optimization", no_argument, 0, 0}, {"force", no_argument, 0, 0}, {"fs-options", required_argument, 0, 0}, {"header-version", required_argument, 0, 0}, @@ -2228,6 +2229,8 @@ int FastBootTool::Main(int argc, char* argv[]) { g_disable_verification = true; } else if (name == "disable-verity") { g_disable_verity = true; + } else if (name == "disable-super-optimization") { + fp->should_optimize_flash_super = false; } else if (name == "force") { fp->force_flash = true; } else if (name == "fs-options") { diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h index 4b48d4a2d..ae488d82d 100644 --- a/fastboot/fastboot.h +++ b/fastboot/fastboot.h @@ -96,6 +96,7 @@ struct FlashingPlan { bool wants_set_active = false; bool skip_secondary = false; bool force_flash = false; + bool should_optimize_flash_super = true; std::string slot_override; std::string current_slot; diff --git a/fastboot/task.cpp b/fastboot/task.cpp index 03f9b8942..96b952c94 100644 --- a/fastboot/task.cpp +++ b/fastboot/task.cpp @@ -124,6 +124,10 @@ std::string FlashSuperLayoutTask::ToString() { std::unique_ptr FlashSuperLayoutTask::Initialize( const FlashingPlan* fp, std::vector& os_images) { + if (!fp->should_optimize_flash_super) { + LOG(INFO) << "super optimization is disabled"; + return nullptr; + } if (!supports_AB()) { LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device"; return nullptr; @@ -188,6 +192,10 @@ std::unique_ptr FlashSuperLayoutTask::Initialize( std::unique_ptr FlashSuperLayoutTask::InitializeFromTasks( const FlashingPlan* fp, std::vector>& tasks) { + if (!fp->should_optimize_flash_super) { + LOG(INFO) << "super optimization is disabled"; + return nullptr; + } if (!supports_AB()) { LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device"; return nullptr;