Do not use block_verify on target-files where feature is missing.

This will only be used when the block file format is at least
version 3.  For V1/V2 (L, L MR1) block versions, fall back to
the old range_sha1 check.

Bug: 19357591
Change-Id: I7cb178b70d48ec3c98cdb88ed1c94cf7797a01d0
This commit is contained in:
Michael Runge
2015-02-11 19:28:08 -08:00
parent af439891e9
commit cad78c12fb

View File

@@ -1068,14 +1068,14 @@ class BlockDifference:
self.partition = partition self.partition = partition
self.check_first_block = check_first_block self.check_first_block = check_first_block
version = 1 self.version = 1
if OPTIONS.info_dict: if OPTIONS.info_dict:
version = max( self.version = max(
int(i) for i in int(i) for i in
OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(",")) OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(","))
b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads, b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads,
version=version) version=self.version)
tmpdir = tempfile.mkdtemp() tmpdir = tempfile.mkdtemp()
OPTIONS.tempfiles.append(tmpdir) OPTIONS.tempfiles.append(tmpdir)
self.path = os.path.join(tmpdir, partition) self.path = os.path.join(tmpdir, partition)
@@ -1098,10 +1098,15 @@ class BlockDifference:
if not self.src: if not self.src:
script.Print("Image %s will be patched unconditionally." % (partition,)) script.Print("Image %s will be patched unconditionally." % (partition,))
else: else:
script.AppendExtra(('if block_image_verify("%s", ' if self.version >= 3:
'package_extract_file("%s.transfer.list"), ' script.AppendExtra(('if block_image_verify("%s", '
'"%s.new.dat", "%s.patch.dat") then') % 'package_extract_file("%s.transfer.list"), '
(self.device, partition, partition, partition)) '"%s.new.dat", "%s.patch.dat") then') %
(self.device, partition, partition, partition))
else:
script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' %
(self.device, self.src.care_map.to_string_raw(),
self.src.TotalSha1()))
script.Print("Verified %s image..." % (partition,)) script.Print("Verified %s image..." % (partition,))
script.AppendExtra('else'); script.AppendExtra('else');