Android: Print the error code string from the client.
The update_engine_client needs to translate the numeric ErrorCode to a
string name that can be printed on the output. This patch moves the
ErrorCodeToString() function to a new error_code_utils.{h,cc} pair of
files so it can be included easily from the client binary and uses it
in the Android update_engine_client.
Bug: 25631767
Bug: 25598547
TEST=`update_engine_client --update` prints the error message in a non-Brillo device.
Change-Id: Ib40813924ec676f3e703412de90d389b2596177e
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 9abb21f..aed2aaa 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -25,6 +25,7 @@
#include <base/time/time.h>
#include "update_engine/common/error_code.h"
+#include "update_engine/common/error_code_utils.h"
#include "update_engine/common/utils.h"
#include "update_engine/update_manager/device_policy_provider.h"
#include "update_engine/update_manager/policy_utils.h"
@@ -76,7 +77,7 @@
case ErrorCode::kUnsupportedMajorPayloadVersion:
case ErrorCode::kUnsupportedMinorPayloadVersion:
LOG(INFO) << "Advancing download URL due to error "
- << chromeos_update_engine::utils::CodeToString(err_code)
+ << chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
return true;
@@ -94,7 +95,7 @@
case ErrorCode::kDownloadStateInitializationError:
case ErrorCode::kOmahaErrorInHTTPResponse: // Aggregate for HTTP errors.
LOG(INFO) << "Incrementing URL failure count due to error "
- << chromeos_update_engine::utils::CodeToString(err_code)
+ << chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
*url_num_error_p += 1;
return false;
@@ -131,7 +132,7 @@
case ErrorCode::kFilesystemVerifierError:
case ErrorCode::kUserCanceled:
LOG(INFO) << "Not changing URL index or failure count due to error "
- << chromeos_update_engine::utils::CodeToString(err_code)
+ << chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
return false;
@@ -147,7 +148,7 @@
// can let the compiler warn about new error codes that are added to
// action_processor.h but not added here.
LOG(WARNING) << "Unexpected error "
- << chromeos_update_engine::utils::CodeToString(err_code)
+ << chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
// Note: Not adding a default here so as to let the compiler warn us of
// any new enums that were added in the .h but not listed in this switch.