diff options
-rw-r--r-- | client_library/client_dbus.cc | 1 | ||||
-rw-r--r-- | client_library/include/update_engine/update_status.h | 17 | ||||
-rw-r--r-- | dbus_service.cc | 1 | ||||
-rw-r--r-- | update_attempter.cc | 1 | ||||
-rw-r--r-- | update_engine_client.cc | 17 | ||||
-rw-r--r-- | update_status_utils.cc | 29 | ||||
-rw-r--r-- | update_status_utils.h | 3 |
7 files changed, 47 insertions, 22 deletions
diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc index d0465029..e2defe7a 100644 --- a/client_library/client_dbus.cc +++ b/client_library/client_dbus.cc @@ -54,6 +54,7 @@ void ConvertToUpdateEngineStatus(const StatusResult& status, out_status->new_version = status.new_version(); out_status->new_size_bytes = status.new_size(); out_status->status = static_cast<UpdateStatus>(status.current_operation()); + out_status->is_install = status.is_install(); } } // namespace diff --git a/client_library/include/update_engine/update_status.h b/client_library/include/update_engine/update_status.h index 059181cc..bc14e675 100644 --- a/client_library/include/update_engine/update_status.h +++ b/client_library/include/update_engine/update_status.h @@ -52,7 +52,7 @@ enum class UpdateStatus { // This value is exclusively used in Chrome. DO NOT define nor use it. // TODO(crbug.com/977320): Remove this value from chrome by refactoring the // Chrome code and evantually from here. This is not really an operation or - // state that the update engine stays on. This is the result of an internal + // state that the update_engine stays on. This is the result of an internal // failure and should be reflected differently. // ERROR = -1, }; @@ -71,19 +71,20 @@ enum UpdateAttemptFlags : int32_t { DECLARE_FLAGS_ENUM(UpdateAttemptFlags); struct UpdateEngineStatus { - // When the update_engine last checked for updates (time_t: seconds from unix - // epoch) + // Update engine last checked update (time_t: seconds from unix epoch). int64_t last_checked_time; - // the current status/operation of the update_engine + // Current status/operation of the update_engine. UpdateStatus status; - // the current product version (oem bundle id) + // Current product version (oem bundle id). std::string current_version; - // The current progress (0.0f-1.0f). + // Current progress (0.0f-1.0f). double progress; - // the size of the update (bytes) + // Size of the update in bytes. uint64_t new_size_bytes; - // the new product version + // New product version. std::string new_version; + // Indication of install for DLC(s). + bool is_install; }; } // namespace update_engine diff --git a/dbus_service.cc b/dbus_service.cc index 0cfe26b4..b3796030 100644 --- a/dbus_service.cc +++ b/dbus_service.cc @@ -47,6 +47,7 @@ void ConvertToStatusResult(const UpdateEngineStatus& ue_status, out_status->set_current_operation(static_cast<Operation>(ue_status.status)); out_status->set_new_version(ue_status.new_version); out_status->set_new_size(ue_status.new_size_bytes); + out_status->set_is_install(ue_status.is_install); } } // namespace diff --git a/update_attempter.cc b/update_attempter.cc index dc7a4b5b..71463b5c 100644 --- a/update_attempter.cc +++ b/update_attempter.cc @@ -1382,6 +1382,7 @@ bool UpdateAttempter::GetStatus(UpdateEngineStatus* out_status) { out_status->progress = download_progress_; out_status->new_size_bytes = new_payload_size_; out_status->new_version = new_version_; + out_status->is_install = is_install_; return true; } diff --git a/update_engine_client.cc b/update_engine_client.cc index 1b680d12..954e856d 100644 --- a/update_engine_client.cc +++ b/update_engine_client.cc @@ -41,6 +41,7 @@ using chromeos_update_engine::EolStatus; using chromeos_update_engine::ErrorCode; +using chromeos_update_engine::UpdateEngineStatusToString; using chromeos_update_engine::UpdateStatusToString; using chromeos_update_engine::utils::ErrorCodeToString; using std::string; @@ -138,12 +139,7 @@ class WatchingStatusUpdateHandler : public ExitingStatusUpdateHandler { void WatchingStatusUpdateHandler::HandleStatusUpdate( const UpdateEngineStatus& status) { - LOG(INFO) << "Got status update:"; - LOG(INFO) << " last_checked_time: " << status.last_checked_time; - LOG(INFO) << " progress: " << status.progress; - LOG(INFO) << " current_operation: " << UpdateStatusToString(status.status); - LOG(INFO) << " new_version: " << status.new_version; - LOG(INFO) << " new_size: " << status.new_size_bytes; + LOG(INFO) << "Got status update: " << UpdateEngineStatusToString(status); } bool UpdateEngineClient::ShowStatus() { @@ -161,14 +157,7 @@ bool UpdateEngineClient::ShowStatus() { base::TimeDelta::FromSeconds(kShowStatusRetryIntervalInSeconds)); } - printf("LAST_CHECKED_TIME=%" PRIi64 - "\nPROGRESS=%f\nCURRENT_OP=%s\n" - "NEW_VERSION=%s\nNEW_SIZE=%" PRIi64 "\n", - status.last_checked_time, - status.progress, - UpdateStatusToString(status.status), - status.new_version.c_str(), - status.new_size_bytes); + printf("%s", UpdateEngineStatusToString(status).c_str()); return true; } diff --git a/update_status_utils.cc b/update_status_utils.cc index f3917d1d..b56d94a1 100644 --- a/update_status_utils.cc +++ b/update_status_utils.cc @@ -16,8 +16,13 @@ #include "update_engine/update_status_utils.h" #include <base/logging.h> +#include <base/strings/string_number_conversions.h> +#include <brillo/key_value_store.h> #include <update_engine/dbus-constants.h> +using brillo::KeyValueStore; +using std::string; +using update_engine::UpdateEngineStatus; using update_engine::UpdateStatus; namespace chromeos_update_engine { @@ -52,4 +57,28 @@ const char* UpdateStatusToString(const UpdateStatus& status) { return nullptr; } +string UpdateEngineStatusToString(const UpdateEngineStatus& status) { + KeyValueStore key_value_store; + +#if BASE_VER < 576279 + key_value_store.SetString("LAST_CHECKED_TIME", + base::Int64ToString(status.last_checked_time)); + key_value_store.SetString("PROGRESS", base::DoubleToString(status.progress)); + key_value_store.SetString("NEW_SIZE", + base::Uint64ToString(status.new_size_bytes)); +#else + key_value_store.SetString("LAST_CHECKED_TIME", + base::NumberToString(status.last_checked_time)); + key_value_store.SetString("PROGRESS", base::NumberToString(status.progress)); + key_value_store.SetString("NEW_SIZE", + base::NumberToString(status.new_size_bytes)); +#endif + key_value_store.SetString("CURRENT_OPERATION", + UpdateStatusToString(status.status)); + key_value_store.SetString("NEW_VERSION", status.new_version); + key_value_store.SetBoolean("IS_INSTALL", status.is_install); + + return key_value_store.SaveToString(); +} + } // namespace chromeos_update_engine diff --git a/update_status_utils.h b/update_status_utils.h index e3b8b43a..1e3fdde5 100644 --- a/update_status_utils.h +++ b/update_status_utils.h @@ -25,6 +25,9 @@ namespace chromeos_update_engine { const char* UpdateStatusToString(const update_engine::UpdateStatus& status); +std::string UpdateEngineStatusToString( + const update_engine::UpdateEngineStatus& status); + } // namespace chromeos_update_engine #endif // UPDATE_ENGINE_UPDATE_STATUS_UTILS_H_ |