Analyze unchanged blocks in odex files.
In BBOTA, we generate patches based on _all_ the blocks of a pair of
input files (src and tgt). For security incremental OTAs, one common
pattern is that only a few blocks are changed in odex files (e.g.
headers). We don't really need to stash/patch the unchanged blocks.
This CL analyzes the unchanged blocks in odex files and computes the
diff for the changed blocks only. It reduces the OTA install time by
about 25% to 40% in our experiments, by paying an increase of 5% to 30%
OTA generation time cost.
Bug: 31570716
Test: Generate an incremental and apply on device.
Change-Id: If842c1afeff6894a3d27eb60b7e8f65a179b7977
diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py
index 1638f8c..fa6eec1 100644
--- a/tools/releasetools/rangelib.py
+++ b/tools/releasetools/rangelib.py
@@ -313,6 +313,20 @@
n -= e - s
return RangeSet(data=out)
+ def next_item(self):
+ """Return the next integer represented by the RangeSet.
+
+ >>> list(RangeSet("0-9").next_item())
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ >>> list(RangeSet("10-19 3-5").next_item())
+ [3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
+ >>> list(rangelib.RangeSet("10-19 3 5 7").next_item())
+ [3, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
+ """
+ for s, e in self:
+ for element in range(s, e):
+ yield element
+
if __name__ == "__main__":
import doctest