Fix attempt number for multi payload.
VerifyPayload() is called for every payload, so we shouldn't call
DownloadComplete() in there, move it to DownloadAction after all
payloads are applied.
Bug: 74980927
Test: check UpdateEngine.SuccessfulUpdate.AttemptCount in log
Test: update_engine_unittests
Change-Id: Iddb0ab111a7893f0c7bbf7a5119bd517ac5410a7
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 0a12801..c38c0b1 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -1766,16 +1766,6 @@
}
LOG(INFO) << "Payload hash matches value in payload.";
-
- // At this point, we are guaranteed to have downloaded a full payload, i.e
- // the one whose size matches the size mentioned in Omaha response. If any
- // errors happen after this, it's likely a problem with the payload itself or
- // the state of the system and not a problem with the URL or network. So,
- // indicate that to the download delegate so that AU can backoff
- // appropriately.
- if (download_delegate_)
- download_delegate_->DownloadComplete();
-
return ErrorCode::kSuccess;
}
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index 3572a6d..e970a56 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -852,9 +852,6 @@
return;
}
- int expected_times = (expected_result == ErrorCode::kSuccess) ? 1 : 0;
- EXPECT_CALL(state->mock_delegate_, DownloadComplete()).Times(expected_times);
-
LOG(INFO) << "Verifying payload for expected result " << expected_result;
brillo::Blob expected_hash;
HashCalculator::RawHashOfData(state->delta, &expected_hash);
@@ -972,12 +969,14 @@
false, kInPlaceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignaturePlaceholderTest) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootSmallImageSignaturePlaceholderTest) {
DoSmallImageTest(false, false, false, -1, kSignatureGeneratedPlaceholder,
false, kInPlaceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignaturePlaceholderMismatchTest) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootSmallImageSignaturePlaceholderMismatchTest) {
DeltaState state;
GenerateDeltaFile(false, false, false, -1,
kSignatureGeneratedPlaceholderMismatch, &state,
@@ -1019,17 +1018,20 @@
false, kInPlaceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignGeneratedShellBadKeyTest) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootSmallImageSignGeneratedShellBadKeyTest) {
DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellBadKey,
false, kInPlaceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignGeneratedShellRotateCl1Test) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootSmallImageSignGeneratedShellRotateCl1Test) {
DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellRotateCl1,
false, kInPlaceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignGeneratedShellRotateCl2Test) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootSmallImageSignGeneratedShellRotateCl2Test) {
DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellRotateCl2,
false, kInPlaceMinorPayloadVersion);
}
@@ -1039,7 +1041,8 @@
false, kSourceMinorPayloadVersion);
}
-TEST(DeltaPerformerIntegrationTest, RunAsRootMandatoryOperationHashMismatchTest) {
+TEST(DeltaPerformerIntegrationTest,
+ RunAsRootMandatoryOperationHashMismatchTest) {
DoOperationHashMismatchTest(kInvalidOperationData, true);
}
diff --git a/payload_consumer/download_action.cc b/payload_consumer/download_action.cc
index f1b6e33..4d46d4f 100644
--- a/payload_consumer/download_action.cc
+++ b/payload_consumer/download_action.cc
@@ -387,8 +387,13 @@
StartDownloading();
return;
}
+
+ // All payloads have been applied and verified.
+ if (delegate_)
+ delegate_->DownloadComplete();
+
// Log UpdateEngine.DownloadAction.* histograms to help diagnose
- // long-blocking oeprations.
+ // long-blocking operations.
std::string histogram_output;
base::StatisticsRecorder::WriteGraph(
"UpdateEngine.DownloadAction.", &histogram_output);
diff --git a/payload_consumer/download_action_unittest.cc b/payload_consumer/download_action_unittest.cc
index 7ec7e0e..daab924 100644
--- a/payload_consumer/download_action_unittest.cc
+++ b/payload_consumer/download_action_unittest.cc
@@ -177,6 +177,8 @@
EXPECT_CALL(download_delegate,
BytesReceived(_, kMockHttpFetcherChunkSize, _));
EXPECT_CALL(download_delegate, BytesReceived(_, _, _)).Times(AtLeast(1));
+ EXPECT_CALL(download_delegate, DownloadComplete())
+ .Times(fail_write == 0 ? 1 : 0);
}
ErrorCode expected_code = ErrorCode::kSuccess;
if (fail_write > 0)