From 5bab0dd1c4bbd72545c1a2f7b5e32e7bfc2550d0 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 10 Jul 2018 17:44:52 -0700 Subject: [PATCH] releasetools: Remove RemoveBackwardEdges(). RemoveBackwardEdges() was used only in BBOTA v1 (which has been deprecated since O). v2+ calls ReverseBackwardEdges() and ImproveVertexSequence(). Also remove the imgdiff tag of 'trimmed' that would be set through this function() only. Test: python -m unittest test_blockimgdiff Test: Build an incremental non-A/B OTA. Test: Code search shows no active user. Change-Id: I3b58ae048a1fbc283269e70fdfa29eb8d184ede7 --- tools/releasetools/blockimgdiff.py | 50 +------------------------ tools/releasetools/test_blockimgdiff.py | 14 ++----- 2 files changed, 5 insertions(+), 59 deletions(-) diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py index 24c5b2de7f..e82e66ab06 100644 --- a/tools/releasetools/blockimgdiff.py +++ b/tools/releasetools/blockimgdiff.py @@ -270,7 +270,6 @@ class ImgdiffStats(object): USED_IMGDIFF_LARGE_APK = "Large APK files split and diff'd with imgdiff" # Reasons for not applying imgdiff on APKs. - SKIPPED_TRIMMED = "Not used imgdiff due to trimmed RangeSet" SKIPPED_NONMONOTONIC = "Not used imgdiff due to having non-monotonic ranges" SKIPPED_SHARED_BLOCKS = "Not used imgdiff due to using shared blocks" SKIPPED_INCOMPLETE = "Not used imgdiff due to incomplete RangeSet" @@ -279,7 +278,6 @@ class ImgdiffStats(object): REASONS = ( USED_IMGDIFF, USED_IMGDIFF_LARGE_APK, - SKIPPED_TRIMMED, SKIPPED_NONMONOTONIC, SKIPPED_SHARED_BLOCKS, SKIPPED_INCOMPLETE, @@ -449,10 +447,6 @@ class BlockImageDiff(object): self.imgdiff_stats.Log(name, ImgdiffStats.SKIPPED_INCOMPLETE) return False - if tgt_ranges.extra.get('trimmed') or src_ranges.extra.get('trimmed'): - self.imgdiff_stats.Log(name, ImgdiffStats.SKIPPED_TRIMMED) - return False - reason = (ImgdiffStats.USED_IMGDIFF_LARGE_APK if large_apk else ImgdiffStats.USED_IMGDIFF) self.imgdiff_stats.Log(name, reason) @@ -836,14 +830,10 @@ class BlockImageDiff(object): str(xf.tgt_ranges), str(xf.src_ranges))) else: if xf.patch: - # We have already generated the patch with imgdiff. Check if the - # transfer is intact. + # We have already generated the patch with imgdiff, while + # splitting large APKs (i.e. in FindTransfers()). assert not self.disable_imgdiff imgdiff = True - if (xf.src_ranges.extra.get('trimmed') or - xf.tgt_ranges.extra.get('trimmed')): - imgdiff = False - xf.patch = None else: imgdiff = self.CanUseImgdiff( xf.tgt_name, xf.tgt_ranges, xf.src_ranges) @@ -1045,42 +1035,6 @@ class BlockImageDiff(object): for i, xf in enumerate(L): xf.order = i - def RemoveBackwardEdges(self): - print("Removing backward edges...") - in_order = 0 - out_of_order = 0 - lost_source = 0 - - for xf in self.transfers: - lost = 0 - size = xf.src_ranges.size() - for u in xf.goes_before: - # xf should go before u - if xf.order < u.order: - # it does, hurray! - in_order += 1 - else: - # it doesn't, boo. trim the blocks that u writes from xf's - # source, so that xf can go after u. - out_of_order += 1 - assert xf.src_ranges.overlaps(u.tgt_ranges) - xf.src_ranges = xf.src_ranges.subtract(u.tgt_ranges) - xf.src_ranges.extra['trimmed'] = True - - if xf.style == "diff" and not xf.src_ranges: - # nothing left to diff from; treat as new data - xf.style = "new" - - lost = size - xf.src_ranges.size() - lost_source += lost - - print((" %d/%d dependencies (%.2f%%) were violated; " - "%d source blocks removed.") % - (out_of_order, in_order + out_of_order, - (out_of_order * 100.0 / (in_order + out_of_order)) - if (in_order + out_of_order) else 0.0, - lost_source)) - def ReverseBackwardEdges(self): """Reverse unsatisfying edges and compute pairs of stashed blocks. diff --git a/tools/releasetools/test_blockimgdiff.py b/tools/releasetools/test_blockimgdiff.py index ceada18ead..124b4d54e8 100644 --- a/tools/releasetools/test_blockimgdiff.py +++ b/tools/releasetools/test_blockimgdiff.py @@ -203,8 +203,8 @@ class BlockImageDiffTest(unittest.TestCase): self.assertDictEqual( { - ImgdiffStats.USED_IMGDIFF : {"/system/app/app1.apk"}, - ImgdiffStats.USED_IMGDIFF_LARGE_APK : {"/vendor/app/app2.apk"}, + ImgdiffStats.USED_IMGDIFF: {"/system/app/app1.apk"}, + ImgdiffStats.USED_IMGDIFF_LARGE_APK: {"/vendor/app/app2.apk"}, }, block_image_diff.imgdiff_stats.stats) @@ -229,13 +229,6 @@ class BlockImageDiffTest(unittest.TestCase): "/system/app/app2.apk", RangeSet("10-15"), RangeSet("15-20 30 10-14"))) - # At least one of the ranges has been modified. - src_ranges = RangeSet("0-5") - src_ranges.extra['trimmed'] = True - self.assertFalse( - block_image_diff.CanUseImgdiff( - "/vendor/app/app3.apk", RangeSet("10-15"), src_ranges)) - # At least one of the ranges is incomplete. src_ranges = RangeSet("0-5") src_ranges.extra['incomplete'] = True @@ -246,8 +239,7 @@ class BlockImageDiffTest(unittest.TestCase): # The stats are correctly logged. self.assertDictEqual( { - ImgdiffStats.SKIPPED_NONMONOTONIC : {'/system/app/app2.apk'}, - ImgdiffStats.SKIPPED_TRIMMED : {'/vendor/app/app3.apk'}, + ImgdiffStats.SKIPPED_NONMONOTONIC: {'/system/app/app2.apk'}, ImgdiffStats.SKIPPED_INCOMPLETE: {'/vendor/app/app4.apk'}, }, block_image_diff.imgdiff_stats.stats)