Use ActionProcessor::IsRunning() to check for ongoing update.
am: 91f8d2aa3f
Change-Id: I430fb9bea7bb10c94612dd772321a10c45c3e526
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index f610149..3ddfd85 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -138,7 +138,7 @@
return LogAndSetError(
error, FROM_HERE, "An update already applied, waiting for reboot");
}
- if (ongoing_update_) {
+ if (processor_->IsRunning()) {
return LogAndSetError(
error, FROM_HERE, "Already processing an update, cancel it first.");
}
@@ -255,7 +255,6 @@
fetcher->SetHeader("User-Agent", headers[kPayloadPropertyUserAgent]);
SetStatusAndNotify(UpdateStatus::UPDATE_AVAILABLE);
- ongoing_update_ = true;
// Just in case we didn't update boot flags yet, make sure they're updated
// before any update processing starts. This will start the update process.
@@ -268,21 +267,21 @@
}
bool UpdateAttempterAndroid::SuspendUpdate(brillo::ErrorPtr* error) {
- if (!ongoing_update_)
+ if (!processor_->IsRunning())
return LogAndSetError(error, FROM_HERE, "No ongoing update to suspend.");
processor_->SuspendProcessing();
return true;
}
bool UpdateAttempterAndroid::ResumeUpdate(brillo::ErrorPtr* error) {
- if (!ongoing_update_)
+ if (!processor_->IsRunning())
return LogAndSetError(error, FROM_HERE, "No ongoing update to resume.");
processor_->ResumeProcessing();
return true;
}
bool UpdateAttempterAndroid::CancelUpdate(brillo::ErrorPtr* error) {
- if (!ongoing_update_)
+ if (!processor_->IsRunning())
return LogAndSetError(error, FROM_HERE, "No ongoing update to cancel.");
processor_->StopProcessing();
return true;
@@ -574,7 +573,6 @@
(error_code == ErrorCode::kSuccess ? UpdateStatus::UPDATED_NEED_REBOOT
: UpdateStatus::IDLE);
SetStatusAndNotify(new_status);
- ongoing_update_ = false;
// The network id is only applicable to one download attempt and once it's
// done the network id should not be re-used anymore.
diff --git a/update_attempter_android.h b/update_attempter_android.h
index f00692e..a8f388c 100644
--- a/update_attempter_android.h
+++ b/update_attempter_android.h
@@ -179,11 +179,6 @@
// Pointer to the DownloadAction in the actions_ vector.
std::shared_ptr<DownloadAction> download_action_;
- // Whether there is an ongoing update. This implies that an update was started
- // but not finished yet. This value will be true even if the update was
- // suspended.
- bool ongoing_update_{false};
-
// The InstallPlan used during the ongoing update.
InstallPlan install_plan_;