Add progress updates to FilesystemVerificationAction
An attempt to fix b/142525610. This CL adds progress reports to
FilesystemVerificationAction. So that clients(e.x. GMSCore) could
properly display a progress bar instead of hanging there for a
few minutes. GMSCore support is already done, see
https://critique-ng.corp.google.com/cl/317362455
Test: Did an OTA update and observed that verification progress
is ported from android OTA client
Bug: 142525610
Change-Id: I1cdb1970cb65fc767b49cd38650894eed4d90960
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index b7d119f..4d74379 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -576,9 +576,9 @@
cleanup_previous_update_code_ = code;
NotifyCleanupPreviousUpdateCallbacksAndClear();
}
- if (type == DownloadAction::StaticType()) {
- download_progress_ = 0;
- }
+ // download_progress_ is actually used by other actions, such as
+ // filesystem_verify_action. Therefore we always clear it.
+ download_progress_ = 0;
if (type == PostinstallRunnerAction::StaticType()) {
bool succeeded =
code == ErrorCode::kSuccess || code == ErrorCode::kUpdatedButNotActive;
@@ -592,8 +592,9 @@
SetStatusAndNotify(UpdateStatus::CLEANUP_PREVIOUS_UPDATE);
}
if (type == DownloadAction::StaticType()) {
- SetStatusAndNotify(UpdateStatus::FINALIZING);
+ SetStatusAndNotify(UpdateStatus::VERIFYING);
} else if (type == FilesystemVerifierAction::StaticType()) {
+ SetStatusAndNotify(UpdateStatus::FINALIZING);
prefs_->SetBoolean(kPrefsVerityWritten, true);
}
}
@@ -644,6 +645,11 @@
}
}
+void UpdateAttempterAndroid::OnVerifyProgressUpdate(double progress) {
+ assert(status_ == UpdateStatus::VERIFYING);
+ ProgressUpdate(progress);
+}
+
void UpdateAttempterAndroid::ScheduleProcessingStart() {
LOG(INFO) << "Scheduling an action processor start.";
brillo::MessageLoop::current()->PostTask(
@@ -734,6 +740,7 @@
std::make_unique<FilesystemVerifierAction>();
auto postinstall_runner_action =
std::make_unique<PostinstallRunnerAction>(boot_control_, hardware_);
+ filesystem_verifier_action->set_delegate(this);
postinstall_runner_action->set_delegate(this);
// Bond them together. We have to use the leaf-types when calling