diff options
author | Christopher Wiley <wiley@google.com> | 2015-10-01 17:17:41 -0700 |
---|---|---|
committer | Christopher Wiley <wiley@google.com> | 2015-10-05 12:42:31 -0700 |
commit | 3f97b5d26350ae4e3029c148189e88b15805bf25 (patch) | |
tree | de25886761f6d224542ae5a55db28fbd27e51708 /update_status_utils.cc | |
parent | cc8ce0e3b11ac76412c26c687d11140cbe18ad91 (diff) |
Add helper to convert strings to UpdateStatus values
This is useful for decyphering the statuses returned over
the DBus interface.
Bug: 24547247
Test: mmm system/update_engine; emerge-panther update_engine
Change-Id: Ifce74450209a7e7cb632c2fee7b54364ffaf3ff5
Diffstat (limited to 'update_status_utils.cc')
-rw-r--r-- | update_status_utils.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/update_status_utils.cc b/update_status_utils.cc index c1504fd4..ff039b8c 100644 --- a/update_status_utils.cc +++ b/update_status_utils.cc @@ -50,4 +50,40 @@ const char* UpdateStatusToString(const UpdateStatus& status) { return nullptr; } +bool StringToUpdateStatus(const std::string& s, + UpdateStatus* status) { + if (s == update_engine::kUpdateStatusIdle) { + *status = UpdateStatus::IDLE; + return true; + } else if (s == update_engine::kUpdateStatusCheckingForUpdate) { + *status = UpdateStatus::CHECKING_FOR_UPDATE; + return true; + } else if (s == update_engine::kUpdateStatusUpdateAvailable) { + *status = UpdateStatus::UPDATE_AVAILABLE; + return true; + } else if (s == update_engine::kUpdateStatusDownloading) { + *status = UpdateStatus::DOWNLOADING; + return true; + } else if (s == update_engine::kUpdateStatusVerifying) { + *status = UpdateStatus::VERIFYING; + return true; + } else if (s == update_engine::kUpdateStatusFinalizing) { + *status = UpdateStatus::FINALIZING; + return true; + } else if (s == update_engine::kUpdateStatusUpdatedNeedReboot) { + *status = UpdateStatus::UPDATED_NEED_REBOOT; + return true; + } else if (s == update_engine::kUpdateStatusReportingErrorEvent) { + *status = UpdateStatus::REPORTING_ERROR_EVENT; + return true; + } else if (s == update_engine::kUpdateStatusAttemptingRollback) { + *status = UpdateStatus::ATTEMPTING_ROLLBACK; + return true; + } else if (s == update_engine::kUpdateStatusDisabled) { + *status = UpdateStatus::DISABLED; + return true; + } + return false; +} + } // namespace chromeos_update_engine |