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_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();
}