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/Android.mk b/Android.mk
index bebcc52..65ae2de 100644
--- a/Android.mk
+++ b/Android.mk
@@ -153,6 +153,7 @@
     common/clock.cc \
     common/constants.cc \
     common/cpu_limiter.cc \
+    common/error_code_utils.cc \
     common/hash_calculator.cc \
     common/http_common.cc \
     common/http_fetcher.cc \
@@ -474,6 +475,7 @@
 LOCAL_SRC_FILES := \
     binder_bindings/android/os/IUpdateEngine.aidl \
     binder_bindings/android/os/IUpdateEngineCallback.aidl \
+    common/error_code_utils.cc \
     update_engine_client_android.cc \
     update_status_utils.cc
 endif  # !defined(BRILLO)
diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc
new file mode 100644
index 0000000..dc9eaf4
--- /dev/null
+++ b/common/error_code_utils.cc
@@ -0,0 +1,153 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/common/error_code_utils.h"
+
+#include <base/strings/string_number_conversions.h>
+
+using std::string;
+
+namespace chromeos_update_engine {
+namespace utils {
+
+string ErrorCodeToString(ErrorCode code) {
+  // If the given code has both parts (i.e. the error code part and the flags
+  // part) then strip off the flags part since the switch statement below
+  // has case statements only for the base error code or a single flag but
+  // doesn't support any combinations of those.
+  if ((static_cast<int>(code) & static_cast<int>(ErrorCode::kSpecialFlags)) &&
+      (static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags)))
+    code = static_cast<ErrorCode>(
+        static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
+  switch (code) {
+    case ErrorCode::kSuccess: return "ErrorCode::kSuccess";
+    case ErrorCode::kError: return "ErrorCode::kError";
+    case ErrorCode::kOmahaRequestError: return "ErrorCode::kOmahaRequestError";
+    case ErrorCode::kOmahaResponseHandlerError:
+      return "ErrorCode::kOmahaResponseHandlerError";
+    case ErrorCode::kFilesystemCopierError:
+      return "ErrorCode::kFilesystemCopierError";
+    case ErrorCode::kPostinstallRunnerError:
+      return "ErrorCode::kPostinstallRunnerError";
+    case ErrorCode::kPayloadMismatchedType:
+      return "ErrorCode::kPayloadMismatchedType";
+    case ErrorCode::kInstallDeviceOpenError:
+      return "ErrorCode::kInstallDeviceOpenError";
+    case ErrorCode::kKernelDeviceOpenError:
+      return "ErrorCode::kKernelDeviceOpenError";
+    case ErrorCode::kDownloadTransferError:
+      return "ErrorCode::kDownloadTransferError";
+    case ErrorCode::kPayloadHashMismatchError:
+      return "ErrorCode::kPayloadHashMismatchError";
+    case ErrorCode::kPayloadSizeMismatchError:
+      return "ErrorCode::kPayloadSizeMismatchError";
+    case ErrorCode::kDownloadPayloadVerificationError:
+      return "ErrorCode::kDownloadPayloadVerificationError";
+    case ErrorCode::kDownloadNewPartitionInfoError:
+      return "ErrorCode::kDownloadNewPartitionInfoError";
+    case ErrorCode::kDownloadWriteError:
+      return "ErrorCode::kDownloadWriteError";
+    case ErrorCode::kNewRootfsVerificationError:
+      return "ErrorCode::kNewRootfsVerificationError";
+    case ErrorCode::kNewKernelVerificationError:
+      return "ErrorCode::kNewKernelVerificationError";
+    case ErrorCode::kSignedDeltaPayloadExpectedError:
+      return "ErrorCode::kSignedDeltaPayloadExpectedError";
+    case ErrorCode::kDownloadPayloadPubKeyVerificationError:
+      return "ErrorCode::kDownloadPayloadPubKeyVerificationError";
+    case ErrorCode::kPostinstallBootedFromFirmwareB:
+      return "ErrorCode::kPostinstallBootedFromFirmwareB";
+    case ErrorCode::kDownloadStateInitializationError:
+      return "ErrorCode::kDownloadStateInitializationError";
+    case ErrorCode::kDownloadInvalidMetadataMagicString:
+      return "ErrorCode::kDownloadInvalidMetadataMagicString";
+    case ErrorCode::kDownloadSignatureMissingInManifest:
+      return "ErrorCode::kDownloadSignatureMissingInManifest";
+    case ErrorCode::kDownloadManifestParseError:
+      return "ErrorCode::kDownloadManifestParseError";
+    case ErrorCode::kDownloadMetadataSignatureError:
+      return "ErrorCode::kDownloadMetadataSignatureError";
+    case ErrorCode::kDownloadMetadataSignatureVerificationError:
+      return "ErrorCode::kDownloadMetadataSignatureVerificationError";
+    case ErrorCode::kDownloadMetadataSignatureMismatch:
+      return "ErrorCode::kDownloadMetadataSignatureMismatch";
+    case ErrorCode::kDownloadOperationHashVerificationError:
+      return "ErrorCode::kDownloadOperationHashVerificationError";
+    case ErrorCode::kDownloadOperationExecutionError:
+      return "ErrorCode::kDownloadOperationExecutionError";
+    case ErrorCode::kDownloadOperationHashMismatch:
+      return "ErrorCode::kDownloadOperationHashMismatch";
+    case ErrorCode::kOmahaRequestEmptyResponseError:
+      return "ErrorCode::kOmahaRequestEmptyResponseError";
+    case ErrorCode::kOmahaRequestXMLParseError:
+      return "ErrorCode::kOmahaRequestXMLParseError";
+    case ErrorCode::kDownloadInvalidMetadataSize:
+      return "ErrorCode::kDownloadInvalidMetadataSize";
+    case ErrorCode::kDownloadInvalidMetadataSignature:
+      return "ErrorCode::kDownloadInvalidMetadataSignature";
+    case ErrorCode::kOmahaResponseInvalid:
+      return "ErrorCode::kOmahaResponseInvalid";
+    case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+      return "ErrorCode::kOmahaUpdateIgnoredPerPolicy";
+    case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+      return "ErrorCode::kOmahaUpdateDeferredPerPolicy";
+    case ErrorCode::kOmahaErrorInHTTPResponse:
+      return "ErrorCode::kOmahaErrorInHTTPResponse";
+    case ErrorCode::kDownloadOperationHashMissingError:
+      return "ErrorCode::kDownloadOperationHashMissingError";
+    case ErrorCode::kDownloadMetadataSignatureMissingError:
+      return "ErrorCode::kDownloadMetadataSignatureMissingError";
+    case ErrorCode::kOmahaUpdateDeferredForBackoff:
+      return "ErrorCode::kOmahaUpdateDeferredForBackoff";
+    case ErrorCode::kPostinstallPowerwashError:
+      return "ErrorCode::kPostinstallPowerwashError";
+    case ErrorCode::kUpdateCanceledByChannelChange:
+      return "ErrorCode::kUpdateCanceledByChannelChange";
+    case ErrorCode::kUmaReportedMax:
+      return "ErrorCode::kUmaReportedMax";
+    case ErrorCode::kOmahaRequestHTTPResponseBase:
+      return "ErrorCode::kOmahaRequestHTTPResponseBase";
+    case ErrorCode::kResumedFlag:
+      return "Resumed";
+    case ErrorCode::kDevModeFlag:
+      return "DevMode";
+    case ErrorCode::kTestImageFlag:
+      return "TestImage";
+    case ErrorCode::kTestOmahaUrlFlag:
+      return "TestOmahaUrl";
+    case ErrorCode::kSpecialFlags:
+      return "ErrorCode::kSpecialFlags";
+    case ErrorCode::kPostinstallFirmwareRONotUpdatable:
+      return "ErrorCode::kPostinstallFirmwareRONotUpdatable";
+    case ErrorCode::kUnsupportedMajorPayloadVersion:
+      return "ErrorCode::kUnsupportedMajorPayloadVersion";
+    case ErrorCode::kUnsupportedMinorPayloadVersion:
+      return "ErrorCode::kUnsupportedMinorPayloadVersion";
+    case ErrorCode::kOmahaRequestXMLHasEntityDecl:
+      return "ErrorCode::kOmahaRequestXMLHasEntityDecl";
+    case ErrorCode::kFilesystemVerifierError:
+      return "ErrorCode::kFilesystemVerifierError";
+    case ErrorCode::kUserCanceled:
+      return "ErrorCode::kUserCanceled";
+    // Don't add a default case to let the compiler warn about newly added
+    // error codes which should be added here.
+  }
+
+  return "Unknown error: " + base::UintToString(static_cast<unsigned>(code));
+}
+
+}  // namespace utils
+}  // namespace chromeos_update_engine
diff --git a/common/error_code_utils.h b/common/error_code_utils.h
new file mode 100644
index 0000000..ae3958e
--- /dev/null
+++ b/common/error_code_utils.h
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef UPDATE_ENGINE_COMMON_ERROR_CODE_UTILS_H_
+#define UPDATE_ENGINE_COMMON_ERROR_CODE_UTILS_H_
+
+#include <string>
+
+#include "update_engine/common/error_code.h"
+
+namespace chromeos_update_engine {
+namespace utils {
+
+// Returns a string representation of the ErrorCodes (either the base
+// error codes or the bit flags) for logging purposes.
+std::string ErrorCodeToString(ErrorCode code);
+
+}  // namespace utils
+}  // namespace chromeos_update_engine
+
+#endif  // UPDATE_ENGINE_COMMON_ERROR_CODE_UTILS_H_
diff --git a/common/utils.cc b/common/utils.cc
index a09b425..91dcfc8 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -993,132 +993,6 @@
   return base_code;
 }
 
-string CodeToString(ErrorCode code) {
-  // If the given code has both parts (i.e. the error code part and the flags
-  // part) then strip off the flags part since the switch statement below
-  // has case statements only for the base error code or a single flag but
-  // doesn't support any combinations of those.
-  if ((static_cast<int>(code) & static_cast<int>(ErrorCode::kSpecialFlags)) &&
-      (static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags)))
-    code = static_cast<ErrorCode>(
-        static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
-  switch (code) {
-    case ErrorCode::kSuccess: return "ErrorCode::kSuccess";
-    case ErrorCode::kError: return "ErrorCode::kError";
-    case ErrorCode::kOmahaRequestError: return "ErrorCode::kOmahaRequestError";
-    case ErrorCode::kOmahaResponseHandlerError:
-      return "ErrorCode::kOmahaResponseHandlerError";
-    case ErrorCode::kFilesystemCopierError:
-      return "ErrorCode::kFilesystemCopierError";
-    case ErrorCode::kPostinstallRunnerError:
-      return "ErrorCode::kPostinstallRunnerError";
-    case ErrorCode::kPayloadMismatchedType:
-      return "ErrorCode::kPayloadMismatchedType";
-    case ErrorCode::kInstallDeviceOpenError:
-      return "ErrorCode::kInstallDeviceOpenError";
-    case ErrorCode::kKernelDeviceOpenError:
-      return "ErrorCode::kKernelDeviceOpenError";
-    case ErrorCode::kDownloadTransferError:
-      return "ErrorCode::kDownloadTransferError";
-    case ErrorCode::kPayloadHashMismatchError:
-      return "ErrorCode::kPayloadHashMismatchError";
-    case ErrorCode::kPayloadSizeMismatchError:
-      return "ErrorCode::kPayloadSizeMismatchError";
-    case ErrorCode::kDownloadPayloadVerificationError:
-      return "ErrorCode::kDownloadPayloadVerificationError";
-    case ErrorCode::kDownloadNewPartitionInfoError:
-      return "ErrorCode::kDownloadNewPartitionInfoError";
-    case ErrorCode::kDownloadWriteError:
-      return "ErrorCode::kDownloadWriteError";
-    case ErrorCode::kNewRootfsVerificationError:
-      return "ErrorCode::kNewRootfsVerificationError";
-    case ErrorCode::kNewKernelVerificationError:
-      return "ErrorCode::kNewKernelVerificationError";
-    case ErrorCode::kSignedDeltaPayloadExpectedError:
-      return "ErrorCode::kSignedDeltaPayloadExpectedError";
-    case ErrorCode::kDownloadPayloadPubKeyVerificationError:
-      return "ErrorCode::kDownloadPayloadPubKeyVerificationError";
-    case ErrorCode::kPostinstallBootedFromFirmwareB:
-      return "ErrorCode::kPostinstallBootedFromFirmwareB";
-    case ErrorCode::kDownloadStateInitializationError:
-      return "ErrorCode::kDownloadStateInitializationError";
-    case ErrorCode::kDownloadInvalidMetadataMagicString:
-      return "ErrorCode::kDownloadInvalidMetadataMagicString";
-    case ErrorCode::kDownloadSignatureMissingInManifest:
-      return "ErrorCode::kDownloadSignatureMissingInManifest";
-    case ErrorCode::kDownloadManifestParseError:
-      return "ErrorCode::kDownloadManifestParseError";
-    case ErrorCode::kDownloadMetadataSignatureError:
-      return "ErrorCode::kDownloadMetadataSignatureError";
-    case ErrorCode::kDownloadMetadataSignatureVerificationError:
-      return "ErrorCode::kDownloadMetadataSignatureVerificationError";
-    case ErrorCode::kDownloadMetadataSignatureMismatch:
-      return "ErrorCode::kDownloadMetadataSignatureMismatch";
-    case ErrorCode::kDownloadOperationHashVerificationError:
-      return "ErrorCode::kDownloadOperationHashVerificationError";
-    case ErrorCode::kDownloadOperationExecutionError:
-      return "ErrorCode::kDownloadOperationExecutionError";
-    case ErrorCode::kDownloadOperationHashMismatch:
-      return "ErrorCode::kDownloadOperationHashMismatch";
-    case ErrorCode::kOmahaRequestEmptyResponseError:
-      return "ErrorCode::kOmahaRequestEmptyResponseError";
-    case ErrorCode::kOmahaRequestXMLParseError:
-      return "ErrorCode::kOmahaRequestXMLParseError";
-    case ErrorCode::kDownloadInvalidMetadataSize:
-      return "ErrorCode::kDownloadInvalidMetadataSize";
-    case ErrorCode::kDownloadInvalidMetadataSignature:
-      return "ErrorCode::kDownloadInvalidMetadataSignature";
-    case ErrorCode::kOmahaResponseInvalid:
-      return "ErrorCode::kOmahaResponseInvalid";
-    case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
-      return "ErrorCode::kOmahaUpdateIgnoredPerPolicy";
-    case ErrorCode::kOmahaUpdateDeferredPerPolicy:
-      return "ErrorCode::kOmahaUpdateDeferredPerPolicy";
-    case ErrorCode::kOmahaErrorInHTTPResponse:
-      return "ErrorCode::kOmahaErrorInHTTPResponse";
-    case ErrorCode::kDownloadOperationHashMissingError:
-      return "ErrorCode::kDownloadOperationHashMissingError";
-    case ErrorCode::kDownloadMetadataSignatureMissingError:
-      return "ErrorCode::kDownloadMetadataSignatureMissingError";
-    case ErrorCode::kOmahaUpdateDeferredForBackoff:
-      return "ErrorCode::kOmahaUpdateDeferredForBackoff";
-    case ErrorCode::kPostinstallPowerwashError:
-      return "ErrorCode::kPostinstallPowerwashError";
-    case ErrorCode::kUpdateCanceledByChannelChange:
-      return "ErrorCode::kUpdateCanceledByChannelChange";
-    case ErrorCode::kUmaReportedMax:
-      return "ErrorCode::kUmaReportedMax";
-    case ErrorCode::kOmahaRequestHTTPResponseBase:
-      return "ErrorCode::kOmahaRequestHTTPResponseBase";
-    case ErrorCode::kResumedFlag:
-      return "Resumed";
-    case ErrorCode::kDevModeFlag:
-      return "DevMode";
-    case ErrorCode::kTestImageFlag:
-      return "TestImage";
-    case ErrorCode::kTestOmahaUrlFlag:
-      return "TestOmahaUrl";
-    case ErrorCode::kSpecialFlags:
-      return "ErrorCode::kSpecialFlags";
-    case ErrorCode::kPostinstallFirmwareRONotUpdatable:
-      return "ErrorCode::kPostinstallFirmwareRONotUpdatable";
-    case ErrorCode::kUnsupportedMajorPayloadVersion:
-      return "ErrorCode::kUnsupportedMajorPayloadVersion";
-    case ErrorCode::kUnsupportedMinorPayloadVersion:
-      return "ErrorCode::kUnsupportedMinorPayloadVersion";
-    case ErrorCode::kOmahaRequestXMLHasEntityDecl:
-      return "ErrorCode::kOmahaRequestXMLHasEntityDecl";
-    case ErrorCode::kFilesystemVerifierError:
-      return "ErrorCode::kFilesystemVerifierError";
-    case ErrorCode::kUserCanceled:
-      return "ErrorCode::kUserCanceled";
-    // Don't add a default case to let the compiler warn about newly added
-    // error codes which should be added here.
-  }
-
-  return "Unknown error: " + base::UintToString(static_cast<unsigned>(code));
-}
-
 bool CreatePowerwashMarkerFile(const char* file_path) {
   const char* marker_file = file_path ? file_path : kPowerwashMarkerFile;
   bool result = utils::WriteFile(marker_file,
diff --git a/common/utils.h b/common/utils.h
index ecb7fb9..5bf1422 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -299,10 +299,6 @@
 // it'll return the same value again.
 ErrorCode GetBaseErrorCode(ErrorCode code);
 
-// Returns a string representation of the ErrorCodes (either the base
-// error codes or the bit flags) for logging purposes.
-std::string CodeToString(ErrorCode code);
-
 // Creates the powerwash marker file with the appropriate commands in it.  Uses
 // |file_path| as the path to the marker file if non-null, otherwise uses the
 // global default. Returns true if successfully created.  False otherwise.
diff --git a/payload_state.cc b/payload_state.cc
index 38a36f9..4b5b5fd 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -27,6 +27,7 @@
 
 #include "update_engine/common/clock.h"
 #include "update_engine/common/constants.h"
+#include "update_engine/common/error_code_utils.h"
 #include "update_engine/common/hardware_interface.h"
 #include "update_engine/common/prefs.h"
 #include "update_engine/common/utils.h"
@@ -242,7 +243,7 @@
 void PayloadState::UpdateFailed(ErrorCode error) {
   ErrorCode base_error = utils::GetBaseErrorCode(error);
   LOG(INFO) << "Updating payload state for error code: " << base_error
-            << " (" << utils::CodeToString(base_error) << ")";
+            << " (" << utils::ErrorCodeToString(base_error) << ")";
 
   if (candidate_urls_.size() == 0) {
     // This means we got this error even before we got a valid Omaha response
diff --git a/update_engine.gyp b/update_engine.gyp
index 7b0597a..ab20243 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -161,6 +161,7 @@
         'common/clock.cc',
         'common/constants.cc',
         'common/cpu_limiter.cc',
+        'common/error_code_utils.cc',
         'common/hash_calculator.cc',
         'common/http_common.cc',
         'common/http_fetcher.cc',
diff --git a/update_engine_client_android.cc b/update_engine_client_android.cc
index 3485807..3006a6f 100644
--- a/update_engine_client_android.cc
+++ b/update_engine_client_android.cc
@@ -39,6 +39,7 @@
 #include "android/os/IUpdateEngine.h"
 #include "update_engine/client_library/include/update_engine/update_status.h"
 #include "update_engine/common/error_code.h"
+#include "update_engine/common/error_code_utils.h"
 #include "update_engine/update_status_utils.h"
 
 using android::binder::Status;
@@ -57,8 +58,7 @@
  private:
   class UECallback : public android::os::BnUpdateEngineCallback {
    public:
-    UECallback(UpdateEngineClientAndroid* client) : client_(client) {
-    }
+    explicit UECallback(UpdateEngineClientAndroid* client) : client_(client) {}
 
     // android::os::BnUpdateEngineCallback overrides.
     Status onStatusUpdate(int status_code, float progress) override;
@@ -95,8 +95,8 @@
 Status UpdateEngineClientAndroid::UECallback::onPayloadApplicationComplete(
     int error_code) {
   ErrorCode code = static_cast<ErrorCode>(error_code);
-  // TODO(deymo): Print the ErrorCode as a string.
-  LOG(INFO) << "onPayloadApplicationComplete(" << error_code << ")";
+  LOG(INFO) << "onPayloadApplicationComplete(" << utils::ErrorCodeToString(code)
+            << " (" << error_code << "))";
   client_->ExitWhenIdle(code == ErrorCode::kSuccess ? EX_OK : 1);
   return Status::ok();
 }
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.