Skip writing verity if already written. Computing FEC on device could take up to 3 minutes depending on partition size, we should skip it if it's already written. This is similar to how we skip postinstall for postponed OTA, but we don't require passing additional header here because we can verify the correctness of the verity data within update_engine itself. Bug: 28171891 Test: update_engine_unittests Change-Id: Ie9883e2260d95c05aec169dd1fde12beea0bdade
diff --git a/update_attempter_android.cc b/update_attempter_android.cc index 97ff6d6..a8be578 100644 --- a/update_attempter_android.cc +++ b/update_attempter_android.cc
@@ -220,13 +220,24 @@ // c) RUN_POST_INSTALL is set to 0. if (install_plan_.is_resume && prefs_->Exists(kPrefsPostInstallSucceeded)) { bool post_install_succeeded = false; - prefs_->GetBoolean(kPrefsPostInstallSucceeded, &post_install_succeeded); - if (post_install_succeeded) { + if (prefs_->GetBoolean(kPrefsPostInstallSucceeded, + &post_install_succeeded) && + post_install_succeeded) { install_plan_.run_post_install = GetHeaderAsBool(headers[kPayloadPropertyRunPostInstall], true); } } + // Skip writing verity if we're resuming and verity has already been written. + install_plan_.write_verity = true; + if (install_plan_.is_resume && prefs_->Exists(kPrefsVerityWritten)) { + bool verity_written = false; + if (prefs_->GetBoolean(kPrefsVerityWritten, &verity_written) && + verity_written) { + install_plan_.write_verity = false; + } + } + NetworkId network_id = kDefaultNetworkId; if (!headers[kPayloadPropertyNetworkId].empty()) { if (!base::StringToUint64(headers[kPayloadPropertyNetworkId], @@ -495,6 +506,8 @@ } if (type == DownloadAction::StaticType()) { SetStatusAndNotify(UpdateStatus::FINALIZING); + } else if (type == FilesystemVerifierAction::StaticType()) { + prefs_->SetBoolean(kPrefsVerityWritten, true); } }