Merge "Fix GetCareMap for small images" am: 8ef44309b2 am: 2dbcae4a5a am: 04d6278863 am: bcf6567964

Original change: https://android-review.googlesource.com/c/platform/build/+/1940646

Change-Id: Ibf3103142e5bb05c4e0e8d5df3b6916e2341d39e
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 339939f..94ef6d8 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -3892,7 +3892,10 @@
   disable_sparse = OPTIONS.info_dict.get(which + "_disable_sparse")
 
   image_blocks = int(image_size) // 4096 - 1
-  assert image_blocks > 0, "blocks for {} must be positive".format(which)
+  # It's OK for image_blocks to be 0, because care map ranges are inclusive.
+  # So 0-0 means "just block 0", which is valid.
+  assert image_blocks >= 0, "blocks for {} must be non-negative, image size: {}".format(
+      which, image_size)
 
   # For sparse images, we will only check the blocks that are listed in the care
   # map, i.e. the ones with meaningful data.