paycheck: Properly infer usable target partition size.

The payload checker used to restrict read/write block indexes to the
reported target filesystem size, unless explicitly given a partition
size value to use instead. So far this value was easy for clients (like
paygen) to come up with, because it was constant at 2GB for all known
boards.  However this is no longer the case, and there is no an easy way
for clients to know the actual target partition size after the payload
has been generated (nor is it encoded in the payload). This adds logic
for inferring the usable target partition size into PayloadChecker()
itself, as follows:

1) If a partition size was given, use that.

2) Else, if this is an old delta (minor version < 2), use the
   aforementioned default. This is necessary because older deltas may
   actually read/write data beyond the filesystem size. It is also
   sufficient because any old delta payload we generate should write to
   a 2GB target partition.

3) In all other cases, just use the new filesystem size, as encoded in
   the payload. This is a safe choice for full updates and newer deltas.

The command-line tool is updated accordingly. Note that the usable
kernel partition size inference remains unaffected.

BUG=chromium:508566
TEST=Unit tests (revised)

Change-Id: I987f28fdfe1d82d0f6f565ae9852b7b11bce13e8
Reviewed-on: https://chromium-review.googlesource.com/285447
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
3 files changed