From e09d096ed6015a4e3d24591ce588ecf8fd66b494 Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Fri, 24 Apr 2015 11:54:01 +0100 Subject: [PATCH] Check partition hash before resorting to block_image_verify It's not necessary to call block_image_verify for the most common case where we attempt an update for the first time and the target partition has expected contents. It is sufficient to confirm that the target partition is intact. Computing a hash is much faster than simulating the update, which means this change should make the update speed for v3 much closer to v2 for the common case. If the update was interrupted, this is going to make resuming somewhat slower, of course. Hopefully this should be rather rare. Bug: 20309033 Change-Id: I04792f3681bf2cd5d9a4e1c41eb883c7f26c6f58 --- tools/releasetools/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 6a5d22fda3..a8b0035efe 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1140,10 +1140,13 @@ class BlockDifference(object): script.Print("Image %s will be patched unconditionally." % (partition,)) else: if self.version >= 3: - script.AppendExtra(('if block_image_verify("%s", ' + script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || ' + 'block_image_verify("%s", ' 'package_extract_file("%s.transfer.list"), ' - '"%s.new.dat", "%s.patch.dat") then') % - (self.device, partition, partition, partition)) + '"%s.new.dat", "%s.patch.dat")) then') % ( + self.device, self.src.care_map.to_string_raw(), + self.src.TotalSha1(), + self.device, partition, partition, partition)) else: script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % ( self.device, self.src.care_map.to_string_raw(),