|
16 | 16 | #include "update_engine/update_status_utils.h"
|
17 | 17 |
|
18 | 18 | #include <base/logging.h>
|
| 19 | +#include <base/strings/string_number_conversions.h> |
| 20 | +#include <brillo/key_value_store.h> |
19 | 21 | #include <update_engine/dbus-constants.h>
|
20 | 22 |
|
| 23 | +using brillo::KeyValueStore; |
| 24 | +using std::string; |
| 25 | +using update_engine::UpdateEngineStatus; |
21 | 26 | using update_engine::UpdateStatus;
|
22 | 27 |
|
23 | 28 | namespace chromeos_update_engine {
|
@@ -52,4 +57,28 @@ const char* UpdateStatusToString(const UpdateStatus& status) {
|
52 | 57 | return nullptr;
|
53 | 58 | }
|
54 | 59 |
|
| 60 | +string UpdateEngineStatusToString(const UpdateEngineStatus& status) { |
| 61 | + KeyValueStore key_value_store; |
| 62 | + |
| 63 | +#if BASE_VER < 576279 |
| 64 | + key_value_store.SetString("LAST_CHECKED_TIME", |
| 65 | + base::Int64ToString(status.last_checked_time)); |
| 66 | + key_value_store.SetString("PROGRESS", base::DoubleToString(status.progress)); |
| 67 | + key_value_store.SetString("NEW_SIZE", |
| 68 | + base::Uint64ToString(status.new_size_bytes)); |
| 69 | +#else |
| 70 | + key_value_store.SetString("LAST_CHECKED_TIME", |
| 71 | + base::NumberToString(status.last_checked_time)); |
| 72 | + key_value_store.SetString("PROGRESS", base::NumberToString(status.progress)); |
| 73 | + key_value_store.SetString("NEW_SIZE", |
| 74 | + base::NumberToString(status.new_size_bytes)); |
| 75 | +#endif |
| 76 | + key_value_store.SetString("CURRENT_OPERATION", |
| 77 | + UpdateStatusToString(status.status)); |
| 78 | + key_value_store.SetString("NEW_VERSION", status.new_version); |
| 79 | + key_value_store.SetBoolean("IS_INSTALL", status.is_install); |
| 80 | + |
| 81 | + return key_value_store.SaveToString(); |
| 82 | +} |
| 83 | + |
55 | 84 | } // namespace chromeos_update_engine
|
0 commit comments