From 29f529f33e5288efd8823cdc935260cfb0d8c7fa Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Fri, 17 Apr 2015 16:28:08 +0100 Subject: [PATCH] Calculate max_stashed_blocks correctly for block OTA v3 The updater automatically stashes overlapping source blocks to make it possible to resume if the command performing the update is interrupted. However, blockimgdiff.py does not take this into account and therefore, max_stashed_blocks indicates only the number of explicitly stashed blocks. Change blockimgdiff.py to correctly calculate the maximum used stash space, including any automatically stashed blocks. Bug: 20309033 Change-Id: Ibf5cb1abc38c54e60a6ad3ce4cbce43556b08ac2 --- tools/releasetools/blockimgdiff.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py index 75379cd49..8eb249afb 100644 --- a/tools/releasetools/blockimgdiff.py +++ b/tools/releasetools/blockimgdiff.py @@ -396,6 +396,12 @@ class BlockImageDiff(object): xf.style, xf.tgt_ranges.to_string_raw(), src_str)) elif self.version >= 3: + # take into account automatic stashing of overlapping blocks + if xf.src_ranges.overlaps(xf.tgt_ranges): + temp_stash_usage = stashed_blocks + xf.src_ranges.size(); + if temp_stash_usage > max_stashed_blocks: + max_stashed_blocks = temp_stash_usage + out.append("%s %s %s %s\n" % ( xf.style, self.HashBlocks(self.tgt, xf.tgt_ranges), @@ -414,6 +420,12 @@ class BlockImageDiff(object): xf.style, xf.patch_start, xf.patch_len, xf.tgt_ranges.to_string_raw(), src_str)) elif self.version >= 3: + # take into account automatic stashing of overlapping blocks + if xf.src_ranges.overlaps(xf.tgt_ranges): + temp_stash_usage = stashed_blocks + xf.src_ranges.size(); + if temp_stash_usage > max_stashed_blocks: + max_stashed_blocks = temp_stash_usage + out.append("%s %d %d %s %s %s %s\n" % ( xf.style, xf.patch_start, xf.patch_len,