Update API: initial support
Initial pieces of the Update API callback framework.
- move the status callback params to a new object, UpdateEngineStatus to
allow for the easier addition of new params in the future.
- switch the IUpdateEngineStatusCallback to provide a
ParcelableUpdateEngineStatus instead of a series of individual params
- move the various GetStatus() methods to use the UpdateEngineStatus
object instead of a series of params (which will need future expansion)
- Add current and new product/os versions to both the UpdateEngineStatus
and the ParcelableUpdateEngineStatus.
Bug: 64808702
Test: unit tests, and performing OTAs via a test app calling
IUpdateEngine::AttemptUpdate() via UpdateManager::performUpdateNow()
Change-Id: I53f66f3511049f0809855814e1e758023cd8cc08
(cherry picked from commit 4f96ebf85022837603f2e10100a044d234b7d86f)
diff --git a/update_attempter.cc b/update_attempter.cc
index 9cf9368..31ebb97 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -78,6 +78,7 @@
using std::shared_ptr;
using std::string;
using std::vector;
+using update_engine::UpdateEngineStatus;
namespace chromeos_update_engine {
@@ -1034,6 +1035,7 @@
const InstallPlan& plan = response_handler_action_->install_plan();
UpdateLastCheckedTime();
new_version_ = plan.version;
+ new_system_version_ = plan.system_version;
new_payload_size_ = 0;
for (const auto& payload : plan.payloads)
new_payload_size_ += payload.size;
@@ -1127,16 +1129,15 @@
}
}
-bool UpdateAttempter::GetStatus(int64_t* last_checked_time,
- double* progress,
- string* current_operation,
- string* new_version,
- int64_t* new_payload_size) {
- *last_checked_time = last_checked_time_;
- *progress = download_progress_;
- *current_operation = UpdateStatusToString(status_);
- *new_version = new_version_;
- *new_payload_size = new_payload_size_;
+bool UpdateAttempter::GetStatus(UpdateEngineStatus* out_status) {
+ out_status->last_checked_time_ms = last_checked_time_;
+ out_status->status = status_;
+ out_status->current_version = omaha_request_params_->app_version();
+ out_status->current_system_version = omaha_request_params_->system_version();
+ out_status->progress = download_progress_;
+ out_status->new_size_bytes = new_payload_size_;
+ out_status->new_version = new_version_;
+ out_status->new_system_version = new_system_version_;
return true;
}
@@ -1173,12 +1174,12 @@
}
void UpdateAttempter::BroadcastStatus() {
+ UpdateEngineStatus broadcast_status;
+ // Use common method for generating the current status.
+ GetStatus(&broadcast_status);
+
for (const auto& observer : service_observers_) {
- observer->SendStatusUpdate(last_checked_time_,
- download_progress_,
- status_,
- new_version_,
- new_payload_size_);
+ observer->SendStatusUpdate(broadcast_status);
}
last_notify_time_ = TimeTicks::Now();
}