Reset payload index in payload state.

If an update failed and we try to update again without reboot, we
should always start from payload index 0.

Bug: 36252799
Test: mma
Change-Id: I337c5bde07f9e8f4b67f10d53fdb4c108aff9d00
(cherry picked from commit 01f6472a938880c128c6d29c164abbd85a03c1bc)
diff --git a/payload_state.cc b/payload_state.cc
index 987cf1c..a1a9d72 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -122,6 +122,10 @@
     return;
   }
 
+  // Always start from payload index 0, even for resume, to download partition
+  // info from previous payloads.
+  payload_index_ = 0;
+
   // This is the earliest point at which we can validate whether the URL index
   // we loaded from the persisted state is a valid value. If the response
   // hasn't changed but the URL index is invalid, it's indicative of some
@@ -240,6 +244,7 @@
   // Reset the number of responses seen since it counts from the last
   // successful update, e.g. now.
   SetNumResponsesSeen(0);
+  SetPayloadIndex(0);
 
   CreateSystemUpdatedMarkerFile();
 }
@@ -762,6 +767,7 @@
 void PayloadState::ResetPersistedState() {
   SetPayloadAttemptNumber(0);
   SetFullPayloadAttemptNumber(0);
+  SetPayloadIndex(0);
   SetUrlIndex(0);
   SetUrlFailureCount(0);
   SetUrlSwitchCount(0);