Support generation of partial updates

Add a new minor version kPartialUpdateMinorPayloadVersion for
partial updates. Also, we always treat the partial update as a
delta update in payload consumer, so new update_engine can
perform minor version check correctly.

Conceptually, partial update is indeed a delta update; because we
need to copy | use the untouched partitions. Since the payload for
the partial update doesn't carry old partition info, old update
engines will treat them as full update. So old UE will also fail
the minor version check correctly; because we always expect
kFullPayloadMinorVersion for full updates.

Bug: 157778739
Test: generate & apply partial full|incremental updates, generate
regular updates, unittests pass

Change-Id: I7f8365cf99098269150dd08e028120354944f3c6
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 68f38df..d8f0ef5 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -1579,9 +1579,12 @@
                                     });
 
   // The presence of an old partition hash is the sole indicator for a delta
-  // update.
+  // update. Also, always treat the partial update as delta so that we can
+  // perform the minor version check correctly.
   InstallPayloadType actual_payload_type =
-      has_old_fields ? InstallPayloadType::kDelta : InstallPayloadType::kFull;
+      (has_old_fields || manifest_.partial_update())
+          ? InstallPayloadType::kDelta
+          : InstallPayloadType::kFull;
 
   if (payload_->type == InstallPayloadType::kUnknown) {
     LOG(INFO) << "Detected a '"
diff --git a/payload_consumer/payload_constants.cc b/payload_consumer/payload_constants.cc
index 1c987bd..28404fe 100644
--- a/payload_consumer/payload_constants.cc
+++ b/payload_consumer/payload_constants.cc
@@ -33,6 +33,7 @@
 const uint32_t kBrotliBsdiffMinorPayloadVersion = 4;
 const uint32_t kPuffdiffMinorPayloadVersion = 5;
 const uint32_t kVerityMinorPayloadVersion = 6;
+const uint32_t kPartialUpdateMinorPayloadVersion = 7;
 
 const uint32_t kMinSupportedMinorPayloadVersion = kSourceMinorPayloadVersion;
 const uint32_t kMaxSupportedMinorPayloadVersion = kVerityMinorPayloadVersion;
diff --git a/payload_consumer/payload_constants.h b/payload_consumer/payload_constants.h
index 5c2d17c..03647ee 100644
--- a/payload_consumer/payload_constants.h
+++ b/payload_consumer/payload_constants.h
@@ -56,6 +56,9 @@
 // The minor version that allows Verity hash tree and FEC generation.
 extern const uint32_t kVerityMinorPayloadVersion;
 
+// The minor version that allows partial update, e.g. kernel only update.
+extern const uint32_t kPartialUpdateMinorPayloadVersion;
+
 // The minimum and maximum supported minor version.
 extern const uint32_t kMinSupportedMinorPayloadVersion;
 extern const uint32_t kMaxSupportedMinorPayloadVersion;