Loading applypatch/imgdiff.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -1038,20 +1038,21 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, split_tgt_image.Initialize(aligned_tgt_chunks, {}); split_tgt_image.MergeAdjacentNormalChunks(); // Construct the dummy source file based on the src_ranges. std::vector<uint8_t> src_content; // Construct the split source file based on the split src ranges. std::vector<uint8_t> split_src_content; for (const auto& r : split_src_ranges) { size_t end = std::min(src_image.file_content_.size(), r.second * BLOCK_SIZE); src_content.insert(src_content.end(), src_image.file_content_.begin() + r.first * BLOCK_SIZE, split_src_content.insert(split_src_content.end(), src_image.file_content_.begin() + r.first * BLOCK_SIZE, src_image.file_content_.begin() + end); } // We should not have an empty src in our design; otherwise we will encounter an error in // bsdiff since src_content.data() == nullptr. CHECK(!src_content.empty()); // bsdiff since split_src_content.data() == nullptr. CHECK(!split_src_content.empty()); ZipModeImage split_src_image(true); split_src_image.Initialize(split_src_chunks, src_content); split_src_image.Initialize(split_src_chunks, split_src_content); split_tgt_images->push_back(std::move(split_tgt_image)); split_src_images->push_back(std::move(split_src_image)); Loading applypatch/include/applypatch/imgdiff_image.h +2 −2 Original line number Diff line number Diff line Loading @@ -211,7 +211,7 @@ class ZipModeImage : public Image { bool Initialize(const std::string& filename) override; // Initialize a dummy ZipModeImage from an existing ImageChunk vector. For src img pieces, we // Initialize a fake ZipModeImage from an existing ImageChunk vector. For src img pieces, we // reconstruct a new file_content based on the source ranges; but it's not needed for the tgt img // pieces; because for each chunk both the data and their offset within the file are unchanged. void Initialize(const std::vector<ImageChunk>& chunks, const std::vector<uint8_t>& file_content) { Loading Loading @@ -265,7 +265,7 @@ class ZipModeImage : public Image { const std::vector<ZipModeImage>& split_src_images, std::vector<SortedRangeSet>& split_src_ranges, size_t total_tgt_size); // Construct the dummy split images based on the chunks info and source ranges; and move them into // Construct the fake split images based on the chunks info and source ranges; and move them into // the given vectors. Return true if we add a new split image into |split_tgt_images|, and // false otherwise. static bool AddSplitImageFromChunkList(const ZipModeImage& tgt_image, Loading otautil/include/otautil/error_code.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ enum ErrorCode : int { kLowBattery = 20, kZipVerificationFailure, kZipOpenFailure, kBootreasonInBlacklist, kBootreasonInBlocklist, kPackageCompatibilityFailure, kScriptExecutionFailure, kMapFileFailure, Loading recovery.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -559,15 +559,15 @@ static void set_retry_bootloader_message(int retry_count, const std::vector<std: } } static bool bootreason_in_blacklist() { static bool bootreason_in_blocklist() { std::string bootreason = android::base::GetProperty("ro.boot.bootreason", ""); if (!bootreason.empty()) { // More bootreasons can be found in "system/core/bootstat/bootstat.cpp". static const std::vector<std::string> kBootreasonBlacklist{ static const std::vector<std::string> kBootreasonBlocklist{ "kernel_panic", "Panic", }; for (const auto& str : kBootreasonBlacklist) { for (const auto& str : kBootreasonBlocklist) { if (android::base::EqualsIgnoreCase(str, bootreason)) return true; } } Loading Loading @@ -734,10 +734,10 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri // Log the error code to last_install when installation skips due to low battery. log_failure_code(kLowBattery, update_package); status = INSTALL_SKIPPED; } else if (retry_count == 0 && bootreason_in_blacklist()) { } else if (retry_count == 0 && bootreason_in_blocklist()) { // Skip update-on-reboot when bootreason is kernel_panic or similar ui->Print("bootreason is in the blacklist; skip OTA installation\n"); log_failure_code(kBootreasonInBlacklist, update_package); ui->Print("bootreason is in the blocklist; skip OTA installation\n"); log_failure_code(kBootreasonInBlocklist, update_package); status = INSTALL_SKIPPED; } else { // It's a fresh update. Initialize the retry_count in the BCB to 1; therefore we can later Loading tests/testdata/ziptest_dummy-update.zip→tests/testdata/ziptest_fake-update.zip (1.04 MiB) File moved. View file Loading
applypatch/imgdiff.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -1038,20 +1038,21 @@ bool ZipModeImage::AddSplitImageFromChunkList(const ZipModeImage& tgt_image, split_tgt_image.Initialize(aligned_tgt_chunks, {}); split_tgt_image.MergeAdjacentNormalChunks(); // Construct the dummy source file based on the src_ranges. std::vector<uint8_t> src_content; // Construct the split source file based on the split src ranges. std::vector<uint8_t> split_src_content; for (const auto& r : split_src_ranges) { size_t end = std::min(src_image.file_content_.size(), r.second * BLOCK_SIZE); src_content.insert(src_content.end(), src_image.file_content_.begin() + r.first * BLOCK_SIZE, split_src_content.insert(split_src_content.end(), src_image.file_content_.begin() + r.first * BLOCK_SIZE, src_image.file_content_.begin() + end); } // We should not have an empty src in our design; otherwise we will encounter an error in // bsdiff since src_content.data() == nullptr. CHECK(!src_content.empty()); // bsdiff since split_src_content.data() == nullptr. CHECK(!split_src_content.empty()); ZipModeImage split_src_image(true); split_src_image.Initialize(split_src_chunks, src_content); split_src_image.Initialize(split_src_chunks, split_src_content); split_tgt_images->push_back(std::move(split_tgt_image)); split_src_images->push_back(std::move(split_src_image)); Loading
applypatch/include/applypatch/imgdiff_image.h +2 −2 Original line number Diff line number Diff line Loading @@ -211,7 +211,7 @@ class ZipModeImage : public Image { bool Initialize(const std::string& filename) override; // Initialize a dummy ZipModeImage from an existing ImageChunk vector. For src img pieces, we // Initialize a fake ZipModeImage from an existing ImageChunk vector. For src img pieces, we // reconstruct a new file_content based on the source ranges; but it's not needed for the tgt img // pieces; because for each chunk both the data and their offset within the file are unchanged. void Initialize(const std::vector<ImageChunk>& chunks, const std::vector<uint8_t>& file_content) { Loading Loading @@ -265,7 +265,7 @@ class ZipModeImage : public Image { const std::vector<ZipModeImage>& split_src_images, std::vector<SortedRangeSet>& split_src_ranges, size_t total_tgt_size); // Construct the dummy split images based on the chunks info and source ranges; and move them into // Construct the fake split images based on the chunks info and source ranges; and move them into // the given vectors. Return true if we add a new split image into |split_tgt_images|, and // false otherwise. static bool AddSplitImageFromChunkList(const ZipModeImage& tgt_image, Loading
otautil/include/otautil/error_code.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ enum ErrorCode : int { kLowBattery = 20, kZipVerificationFailure, kZipOpenFailure, kBootreasonInBlacklist, kBootreasonInBlocklist, kPackageCompatibilityFailure, kScriptExecutionFailure, kMapFileFailure, Loading
recovery.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -559,15 +559,15 @@ static void set_retry_bootloader_message(int retry_count, const std::vector<std: } } static bool bootreason_in_blacklist() { static bool bootreason_in_blocklist() { std::string bootreason = android::base::GetProperty("ro.boot.bootreason", ""); if (!bootreason.empty()) { // More bootreasons can be found in "system/core/bootstat/bootstat.cpp". static const std::vector<std::string> kBootreasonBlacklist{ static const std::vector<std::string> kBootreasonBlocklist{ "kernel_panic", "Panic", }; for (const auto& str : kBootreasonBlacklist) { for (const auto& str : kBootreasonBlocklist) { if (android::base::EqualsIgnoreCase(str, bootreason)) return true; } } Loading Loading @@ -734,10 +734,10 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri // Log the error code to last_install when installation skips due to low battery. log_failure_code(kLowBattery, update_package); status = INSTALL_SKIPPED; } else if (retry_count == 0 && bootreason_in_blacklist()) { } else if (retry_count == 0 && bootreason_in_blocklist()) { // Skip update-on-reboot when bootreason is kernel_panic or similar ui->Print("bootreason is in the blacklist; skip OTA installation\n"); log_failure_code(kBootreasonInBlacklist, update_package); ui->Print("bootreason is in the blocklist; skip OTA installation\n"); log_failure_code(kBootreasonInBlocklist, update_package); status = INSTALL_SKIPPED; } else { // It's a fresh update. Initialize the retry_count in the BCB to 1; therefore we can later Loading
tests/testdata/ziptest_dummy-update.zip→tests/testdata/ziptest_fake-update.zip (1.04 MiB) File moved. View file