Record the source build fingerprint in SnapshotMergeStats.

This also adds a manual call to WriteState(). If update_engine crashes
or the device reboots, it's possible that certain stats (such as the COW
file stats) will be gone by the time the merge state is recovered.
Forcing a write prevents this.

Note that the write was previously implicit in set_cow_file_size, but is
now explicit before calling InitiateMerge().

Bug: 188909957
Test: manual test
Change-Id: I27cdc72272a9fa4ff5df4968e200fc14f63d0146
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index 51bb083..aa24297 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -419,6 +419,14 @@
   merge_stats_->set_boot_complete_to_merge_start_time_ms(
       merge_start_time.count() - merge_stats_->boot_complete_time_ms());
 
+  auto source_build_fingerprint = snapshot_->ReadSourceBuildFingerprint();
+  merge_stats_->set_source_build_fingerprint(source_build_fingerprint);
+
+  if (!merge_stats_->WriteState()) {
+    LOG(ERROR) << "Failed to write merge stats; record may be unreliable if "
+                  "merge is interrupted.";
+  }
+
   if (snapshot_->InitiateMerge()) {
     WaitForMergeOrSchedule();
     return;