Loading fastboot/fastboot.cpp +29 −19 Original line number Diff line number Diff line Loading @@ -1185,9 +1185,10 @@ static uint64_t get_partition_size(const std::string& partition) { return partition_size; } static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) { static void copy_avb_footer(const ImageSource* source, const std::string& partition, struct fastboot_buffer* buf) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) || should_flash_in_userspace(partition)) { should_flash_in_userspace(source, partition)) { return; } // If overflows and negative, it should be < buf->sz. Loading Loading @@ -1244,9 +1245,9 @@ void flash_partition_files(const std::string& partition, const std::vector<Spars } } static void flash_buf(const std::string& partition, struct fastboot_buffer* buf, const bool apply_vbmeta) { copy_avb_footer(partition, buf); static void flash_buf(const ImageSource* source, const std::string& partition, struct fastboot_buffer* buf, const bool apply_vbmeta) { copy_avb_footer(source, partition, buf); // Rewrite vbmeta if that's what we're flashing and modification has been requested. if (g_disable_verity || g_disable_verification) { Loading Loading @@ -1524,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(flash_pname, &buf, apply_vbmeta); flash_buf(fp->source, flash_pname, &buf, apply_vbmeta); } // Sets slot_override as the active slot. If slot_override is blank, Loading Loading @@ -1807,9 +1808,9 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() { tasks = CollectTasksFromImageList(); } if (fp_->exclude_dynamic_partitions) { auto is_non_static_flash_task = [](const auto& task) -> bool { auto is_non_static_flash_task = [&](const auto& task) -> bool { if (auto flash_task = task->AsFlashTask()) { if (!should_flash_in_userspace(flash_task->GetPartitionAndSlot())) { if (!should_flash_in_userspace(fp_->source, flash_task->GetPartitionAndSlot())) { return false; } } Loading Loading @@ -1885,7 +1886,7 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // this, we delete any logical partitions for the "other" slot. if (is_retrofit_device(fp_->source)) { std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(partition_name)) { if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) { tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } Loading Loading @@ -2087,7 +2088,8 @@ void fb_perform_format(const std::string& partition, int skip_if_not_supported, if (!load_buf_fd(std::move(fd), &buf, fp)) { die("Cannot read image: %s", strerror(errno)); } flash_buf(partition, &buf, is_vbmeta_partition(partition)); flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition)); return; failed: Loading @@ -2101,7 +2103,8 @@ failed: } } bool should_flash_in_userspace(const std::string& partition_name) { bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name) { if (!source) { if (!get_android_product_out()) { return false; } Loading @@ -2115,6 +2118,13 @@ bool should_flash_in_userspace(const std::string& partition_name) { } return should_flash_in_userspace(*metadata.get(), partition_name); } std::vector<char> contents; if (!source->ReadFile("super_empty.img", &contents)) { return false; } auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size()); return should_flash_in_userspace(*metadata.get(), partition_name); } static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::string& slot, std::string* message, const FlashingPlan* fp) { Loading fastboot/fastboot.h +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class LocalImageSource final : public ImageSource { }; char* get_android_product_out(); bool should_flash_in_userspace(const std::string& partition_name); bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name); bool is_userspace_fastboot(); void do_flash(const char* pname, const char* fname, const bool apply_vbmeta, const FlashingPlan* fp); Loading fastboot/task.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ bool FlashTask::IsDynamicParitition(const ImageSource* source, const FlashTask* void FlashTask::Run() { auto flash = [&](const std::string& partition) { if (should_flash_in_userspace(partition) && !is_userspace_fastboot() && !fp_->force_flash) { if (should_flash_in_userspace(fp_->source, 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" "\n" Loading Loading
fastboot/fastboot.cpp +29 −19 Original line number Diff line number Diff line Loading @@ -1185,9 +1185,10 @@ static uint64_t get_partition_size(const std::string& partition) { return partition_size; } static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) { static void copy_avb_footer(const ImageSource* source, const std::string& partition, struct fastboot_buffer* buf) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) || should_flash_in_userspace(partition)) { should_flash_in_userspace(source, partition)) { return; } // If overflows and negative, it should be < buf->sz. Loading Loading @@ -1244,9 +1245,9 @@ void flash_partition_files(const std::string& partition, const std::vector<Spars } } static void flash_buf(const std::string& partition, struct fastboot_buffer* buf, const bool apply_vbmeta) { copy_avb_footer(partition, buf); static void flash_buf(const ImageSource* source, const std::string& partition, struct fastboot_buffer* buf, const bool apply_vbmeta) { copy_avb_footer(source, partition, buf); // Rewrite vbmeta if that's what we're flashing and modification has been requested. if (g_disable_verity || g_disable_verification) { Loading Loading @@ -1524,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(flash_pname, &buf, apply_vbmeta); flash_buf(fp->source, flash_pname, &buf, apply_vbmeta); } // Sets slot_override as the active slot. If slot_override is blank, Loading Loading @@ -1807,9 +1808,9 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() { tasks = CollectTasksFromImageList(); } if (fp_->exclude_dynamic_partitions) { auto is_non_static_flash_task = [](const auto& task) -> bool { auto is_non_static_flash_task = [&](const auto& task) -> bool { if (auto flash_task = task->AsFlashTask()) { if (!should_flash_in_userspace(flash_task->GetPartitionAndSlot())) { if (!should_flash_in_userspace(fp_->source, flash_task->GetPartitionAndSlot())) { return false; } } Loading Loading @@ -1885,7 +1886,7 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // this, we delete any logical partitions for the "other" slot. if (is_retrofit_device(fp_->source)) { std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(partition_name)) { if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) { tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } Loading Loading @@ -2087,7 +2088,8 @@ void fb_perform_format(const std::string& partition, int skip_if_not_supported, if (!load_buf_fd(std::move(fd), &buf, fp)) { die("Cannot read image: %s", strerror(errno)); } flash_buf(partition, &buf, is_vbmeta_partition(partition)); flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition)); return; failed: Loading @@ -2101,7 +2103,8 @@ failed: } } bool should_flash_in_userspace(const std::string& partition_name) { bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name) { if (!source) { if (!get_android_product_out()) { return false; } Loading @@ -2115,6 +2118,13 @@ bool should_flash_in_userspace(const std::string& partition_name) { } return should_flash_in_userspace(*metadata.get(), partition_name); } std::vector<char> contents; if (!source->ReadFile("super_empty.img", &contents)) { return false; } auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size()); return should_flash_in_userspace(*metadata.get(), partition_name); } static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::string& slot, std::string* message, const FlashingPlan* fp) { Loading
fastboot/fastboot.h +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class LocalImageSource final : public ImageSource { }; char* get_android_product_out(); bool should_flash_in_userspace(const std::string& partition_name); bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name); bool is_userspace_fastboot(); void do_flash(const char* pname, const char* fname, const bool apply_vbmeta, const FlashingPlan* fp); Loading
fastboot/task.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ bool FlashTask::IsDynamicParitition(const ImageSource* source, const FlashTask* void FlashTask::Run() { auto flash = [&](const std::string& partition) { if (should_flash_in_userspace(partition) && !is_userspace_fastboot() && !fp_->force_flash) { if (should_flash_in_userspace(fp_->source, 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" "\n" Loading