Loading fastboot/fastboot.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -1525,7 +1525,7 @@ void do_flash(const char* pname, const char* fname, const bool apply_vbmeta, fb->ResizePartition(pname, std::to_string(buf.image_size)); } std::string flash_pname = repack_ramdisk(pname, &buf, fp->fb); flash_buf(fp->source, flash_pname, &buf, apply_vbmeta); flash_buf(fp->source.get(), flash_pname, &buf, apply_vbmeta); } // Sets slot_override as the active slot. If slot_override is blank, Loading Loading @@ -1679,7 +1679,7 @@ bool AddResizeTasks(const FlashingPlan* fp, std::vector<std::unique_ptr<Task>>* } for (size_t i = 0; i < tasks->size(); i++) { if (auto flash_task = tasks->at(i)->AsFlashTask()) { if (FlashTask::IsDynamicParitition(fp->source, flash_task)) { if (FlashTask::IsDynamicParitition(fp->source.get(), flash_task)) { if (!loc) { loc = i; } Loading Loading @@ -1810,7 +1810,8 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() { 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(fp_->source, flash_task->GetPartitionAndSlot())) { if (!should_flash_in_userspace(fp_->source.get(), flash_task->GetPartitionAndSlot())) { return false; } } Loading Loading @@ -1884,9 +1885,10 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // 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(fp_->source)) { if (is_retrofit_device(fp_->source.get())) { std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) { if (image->IsSecondary() && should_flash_in_userspace(fp_->source.get(), partition_name)) { tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } Loading Loading @@ -1949,8 +1951,7 @@ static void do_update(const char* filename, FlashingPlan* fp) { if (error != 0) { die("failed to open zip file '%s': %s", filename, ErrorCodeString(error)); } ZipImageSource zp = ZipImageSource(zip); fp->source = &zp; fp->source.reset(new ZipImageSource(zip)); FlashAllTool tool(fp); tool.Flash(); Loading @@ -1971,8 +1972,7 @@ unique_fd LocalImageSource::OpenFile(const std::string& name) const { } static void do_flashall(FlashingPlan* fp) { LocalImageSource s = LocalImageSource(); fp->source = &s; fp->source.reset(new LocalImageSource()); FlashAllTool tool(fp); tool.Flash(); } Loading Loading @@ -2089,7 +2089,7 @@ void fb_perform_format(const std::string& partition, int skip_if_not_supported, die("Cannot read image: %s", strerror(errno)); } flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition)); flash_buf(fp->source.get(), partition, &buf, is_vbmeta_partition(partition)); return; failed: Loading fastboot/fastboot.h +2 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #pragma once #include <functional> #include <memory> #include <string> #include "fastboot_driver_interface.h" #include "filesystem.h" Loading Loading @@ -89,7 +90,7 @@ struct FlashingPlan { // 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. ImageSource* source; std::unique_ptr<ImageSource> source; bool wants_wipe = false; bool skip_reboot = false; bool wants_set_active = false; Loading fastboot/task.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ bool FlashTask::IsDynamicParitition(const ImageSource* source, const FlashTask* void FlashTask::Run() { auto flash = [&](const std::string& partition) { if (should_flash_in_userspace(fp_->source, partition) && !is_userspace_fastboot() && if (should_flash_in_userspace(fp_->source.get(), partition) && !is_userspace_fastboot() && !fp_->force_flash) { die("The partition you are trying to flash is dynamic, and " "should be flashed via fastbootd. Please run:\n" Loading Loading @@ -174,7 +174,7 @@ std::unique_ptr<OptimizedFlashSuperTask> OptimizedFlashSuperTask::Initialize( LOG(VERBOSE) << "Cannot optimize flashing super for all slots"; return nullptr; } if (!CanOptimize(fp->source, tasks)) { if (!CanOptimize(fp->source.get(), tasks)) { return nullptr; } Loading fastboot/task_test.cpp +7 −11 Original line number Diff line number Diff line Loading @@ -192,8 +192,7 @@ TEST_F(ParseTest, CorrectTaskLists) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -239,8 +238,7 @@ TEST_F(ParseTest, IsDynamicParitiontest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fastboot::MockFastbootDriver fb; fp->fb = &fb; Loading @@ -260,7 +258,7 @@ TEST_F(ParseTest, IsDynamicParitiontest) { ParseFastbootInfoLine(fp.get(), android::base::Tokenize(test.first, " ")); auto flash_task = task->AsFlashTask(); ASSERT_FALSE(flash_task == nullptr); ASSERT_EQ(FlashTask::IsDynamicParitition(fp->source, flash_task), test.second); ASSERT_EQ(FlashTask::IsDynamicParitition(fp->source.get(), flash_task), test.second); } } Loading @@ -269,8 +267,7 @@ TEST_F(ParseTest, CanOptimizeTest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -301,7 +298,7 @@ TEST_F(ParseTest, CanOptimizeTest) { for (auto& test : patternmatchtest) { std::vector<std::unique_ptr<Task>> tasks = ParseFastbootInfo(fp.get(), test.first); tasks.erase(std::remove_if(tasks.begin(), tasks.end(), remove_if_callback), tasks.end()); ASSERT_EQ(OptimizedFlashSuperTask::CanOptimize(fp->source, tasks), test.second); ASSERT_EQ(OptimizedFlashSuperTask::CanOptimize(fp->source.get(), tasks), test.second); } } Loading @@ -312,8 +309,7 @@ TEST_F(ParseTest, OptimizedFlashSuperPatternMatchTest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -362,7 +358,7 @@ TEST_F(ParseTest, OptimizedFlashSuperPatternMatchTest) { contains_optimized_task = true; } if (auto flash_task = task->AsFlashTask()) { if (FlashTask::IsDynamicParitition(fp->source, flash_task)) { if (FlashTask::IsDynamicParitition(fp->source.get(), flash_task)) { return false; } } Loading Loading
fastboot/fastboot.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -1525,7 +1525,7 @@ void do_flash(const char* pname, const char* fname, const bool apply_vbmeta, fb->ResizePartition(pname, std::to_string(buf.image_size)); } std::string flash_pname = repack_ramdisk(pname, &buf, fp->fb); flash_buf(fp->source, flash_pname, &buf, apply_vbmeta); flash_buf(fp->source.get(), flash_pname, &buf, apply_vbmeta); } // Sets slot_override as the active slot. If slot_override is blank, Loading Loading @@ -1679,7 +1679,7 @@ bool AddResizeTasks(const FlashingPlan* fp, std::vector<std::unique_ptr<Task>>* } for (size_t i = 0; i < tasks->size(); i++) { if (auto flash_task = tasks->at(i)->AsFlashTask()) { if (FlashTask::IsDynamicParitition(fp->source, flash_task)) { if (FlashTask::IsDynamicParitition(fp->source.get(), flash_task)) { if (!loc) { loc = i; } Loading Loading @@ -1810,7 +1810,8 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() { 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(fp_->source, flash_task->GetPartitionAndSlot())) { if (!should_flash_in_userspace(fp_->source.get(), flash_task->GetPartitionAndSlot())) { return false; } } Loading Loading @@ -1884,9 +1885,10 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // 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(fp_->source)) { if (is_retrofit_device(fp_->source.get())) { std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) { if (image->IsSecondary() && should_flash_in_userspace(fp_->source.get(), partition_name)) { tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } Loading Loading @@ -1949,8 +1951,7 @@ static void do_update(const char* filename, FlashingPlan* fp) { if (error != 0) { die("failed to open zip file '%s': %s", filename, ErrorCodeString(error)); } ZipImageSource zp = ZipImageSource(zip); fp->source = &zp; fp->source.reset(new ZipImageSource(zip)); FlashAllTool tool(fp); tool.Flash(); Loading @@ -1971,8 +1972,7 @@ unique_fd LocalImageSource::OpenFile(const std::string& name) const { } static void do_flashall(FlashingPlan* fp) { LocalImageSource s = LocalImageSource(); fp->source = &s; fp->source.reset(new LocalImageSource()); FlashAllTool tool(fp); tool.Flash(); } Loading Loading @@ -2089,7 +2089,7 @@ void fb_perform_format(const std::string& partition, int skip_if_not_supported, die("Cannot read image: %s", strerror(errno)); } flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition)); flash_buf(fp->source.get(), partition, &buf, is_vbmeta_partition(partition)); return; failed: Loading
fastboot/fastboot.h +2 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #pragma once #include <functional> #include <memory> #include <string> #include "fastboot_driver_interface.h" #include "filesystem.h" Loading Loading @@ -89,7 +90,7 @@ struct FlashingPlan { // 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. ImageSource* source; std::unique_ptr<ImageSource> source; bool wants_wipe = false; bool skip_reboot = false; bool wants_set_active = false; Loading
fastboot/task.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ bool FlashTask::IsDynamicParitition(const ImageSource* source, const FlashTask* void FlashTask::Run() { auto flash = [&](const std::string& partition) { if (should_flash_in_userspace(fp_->source, partition) && !is_userspace_fastboot() && if (should_flash_in_userspace(fp_->source.get(), partition) && !is_userspace_fastboot() && !fp_->force_flash) { die("The partition you are trying to flash is dynamic, and " "should be flashed via fastbootd. Please run:\n" Loading Loading @@ -174,7 +174,7 @@ std::unique_ptr<OptimizedFlashSuperTask> OptimizedFlashSuperTask::Initialize( LOG(VERBOSE) << "Cannot optimize flashing super for all slots"; return nullptr; } if (!CanOptimize(fp->source, tasks)) { if (!CanOptimize(fp->source.get(), tasks)) { return nullptr; } Loading
fastboot/task_test.cpp +7 −11 Original line number Diff line number Diff line Loading @@ -192,8 +192,7 @@ TEST_F(ParseTest, CorrectTaskLists) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -239,8 +238,7 @@ TEST_F(ParseTest, IsDynamicParitiontest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fastboot::MockFastbootDriver fb; fp->fb = &fb; Loading @@ -260,7 +258,7 @@ TEST_F(ParseTest, IsDynamicParitiontest) { ParseFastbootInfoLine(fp.get(), android::base::Tokenize(test.first, " ")); auto flash_task = task->AsFlashTask(); ASSERT_FALSE(flash_task == nullptr); ASSERT_EQ(FlashTask::IsDynamicParitition(fp->source, flash_task), test.second); ASSERT_EQ(FlashTask::IsDynamicParitition(fp->source.get(), flash_task), test.second); } } Loading @@ -269,8 +267,7 @@ TEST_F(ParseTest, CanOptimizeTest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -301,7 +298,7 @@ TEST_F(ParseTest, CanOptimizeTest) { for (auto& test : patternmatchtest) { std::vector<std::unique_ptr<Task>> tasks = ParseFastbootInfo(fp.get(), test.first); tasks.erase(std::remove_if(tasks.begin(), tasks.end(), remove_if_callback), tasks.end()); ASSERT_EQ(OptimizedFlashSuperTask::CanOptimize(fp->source, tasks), test.second); ASSERT_EQ(OptimizedFlashSuperTask::CanOptimize(fp->source.get(), tasks), test.second); } } Loading @@ -312,8 +309,7 @@ TEST_F(ParseTest, OptimizedFlashSuperPatternMatchTest) { GTEST_SKIP(); } LocalImageSource s; fp->source = &s; fp->source.reset(new LocalImageSource); fp->sparse_limit = std::numeric_limits<int64_t>::max(); fastboot::MockFastbootDriver fb; Loading Loading @@ -362,7 +358,7 @@ TEST_F(ParseTest, OptimizedFlashSuperPatternMatchTest) { contains_optimized_task = true; } if (auto flash_task = task->AsFlashTask()) { if (FlashTask::IsDynamicParitition(fp->source, flash_task)) { if (FlashTask::IsDynamicParitition(fp->source.get(), flash_task)) { return false; } } Loading