Add a feature to get the last UpdateAttempt ErrorCode from update_engine
For autotest, update_engine test failures are always hard to debug,
since the error message is not clear. Add a new flag 'last_attempt_error'
to get the last UpdateAttempt ErrorCode from update_engine.
Bug:25598547
Test:emerge-peppy update_engine
emerge-peppy update_engine_client
cros flash a test image to DUT.
(on the DUT):update_engine_client --last_attempt_error
Compare the results with the update_engine logs, matched.
Change-Id: Id12681097ed30b0826cad68809f17f934a07e5b2
diff --git a/client_library/client_binder.cc b/client_library/client_binder.cc
index 6f9b7b6..321dfc4 100644
--- a/client_library/client_binder.cc
+++ b/client_library/client_binder.cc
@@ -215,5 +215,16 @@
return true;
}
+bool BinderUpdateEngineClient::GetLastAttemptError(
+ int32_t* last_attempt_error) const {
+ int out_as_int;
+
+ if (!service_->GetLastAttemptError(&out_as_int).isOk())
+ return false;
+
+ *last_attempt_error = out_as_int;
+ return true;
+}
+
} // namespace internal
} // namespace update_engine
diff --git a/client_library/client_binder.h b/client_library/client_binder.h
index 562cee4..72f80dd 100644
--- a/client_library/client_binder.h
+++ b/client_library/client_binder.h
@@ -80,6 +80,8 @@
bool RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
+ bool GetLastAttemptError(int32_t* last_attempt_error) const override;
+
private:
class StatusUpdateCallback :
public android::brillo::BnUpdateEngineStatusCallback {
diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc
index 270a987..0d6b783 100644
--- a/client_library/client_dbus.cc
+++ b/client_library/client_dbus.cc
@@ -225,5 +225,10 @@
nullptr);
}
+bool DBusUpdateEngineClient::GetLastAttemptError(
+ int32_t* last_attempt_error) const {
+ return proxy_->GetLastAttemptError(last_attempt_error, nullptr);
+}
+
} // namespace internal
} // namespace update_engine
diff --git a/client_library/client_dbus.h b/client_library/client_dbus.h
index 507fb5c..02a7e84 100644
--- a/client_library/client_dbus.h
+++ b/client_library/client_dbus.h
@@ -73,6 +73,8 @@
bool RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
+ bool GetLastAttemptError(int32_t* last_attempt_error) const override;
+
private:
void DBusStatusHandlersRegistered(const std::string& interface,
const std::string& signal_name,
diff --git a/client_library/include/update_engine/client.h b/client_library/include/update_engine/client.h
index dc0fb8c..62ac5fb 100644
--- a/client_library/include/update_engine/client.h
+++ b/client_library/include/update_engine/client.h
@@ -112,6 +112,9 @@
// Unregister a status update handler
virtual bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) = 0;
+ // Get the last UpdateAttempt error code.
+ virtual bool GetLastAttemptError(int32_t* last_attempt_error) const = 0;
+
protected:
// Use CreateInstance().
UpdateEngineClient() = default;