Commit 175d8c40 authored by Jae Hoon Kim's avatar Jae Hoon Kim Committed by Commit Bot

UpdateEngineClient leverage GetStatusAdvanced for EOL info

Instead of extension to the |GetEolStatus()| DBus method within
update_engine, it is completely viable for addition of the EOL related
fields into the |GetStatusAdvanced()| DBus method instead.

Within Chrome, the |UpdateEngineClient| will still expose
|GetEolStatus()| (will deprecate in the future crbug.com/1005511), but
now has |GetEolInfo()| method which internally calls
|GetStatsAdvanced()| instead of |GetEolStatus()| of update_engine to get
EOL info.

For eol_date field to be populated from CrOS please follow: chromium:1783897

Bug: 998983
Test: autoninja -C out_${SDK_BOARD}/Release chrome nacl_helper && deploy_chrome --build-dir=out_${SDK_BOARD}/Release --to=$IP
Test: autoninja -C out/Default unit_tests && testing/xvfb.py ./out/Default/unit_tests
Change-Id: I0d4d0e630336a374b3f4bdb546cfbab8ce7a89d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1811185Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701181}
parent 44c6e7fc
......@@ -85,6 +85,11 @@ void FakeUpdateEngineClient::GetEolStatus(GetEolStatusCallback callback) {
update_engine::EndOfLifeStatus::kSupported));
}
void FakeUpdateEngineClient::GetEolInfo(GetEolInfoCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), EolInfo()));
}
void FakeUpdateEngineClient::SetUpdateOverCellularPermission(
bool allowed,
const base::Closure& callback) {
......
......@@ -38,6 +38,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeUpdateEngineClient
void GetChannel(bool get_current_channel,
const GetChannelCallback& callback) override;
void GetEolStatus(GetEolStatusCallback callback) override;
void GetEolInfo(GetEolInfoCallback callback) override;
void SetUpdateOverCellularPermission(bool allowed,
const base::Closure& callback) override;
void SetUpdateOverCellularOneTimePermission(
......
......@@ -199,6 +199,17 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void GetEolInfo(GetEolInfoCallback callback) override {
dbus::MethodCall method_call(update_engine::kUpdateEngineInterface,
update_engine::kGetStatusAdvanced);
VLOG(1) << "Requesting to get end of life status";
update_engine_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&UpdateEngineClientImpl::OnGetEolInfo,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void SetUpdateOverCellularPermission(bool allowed,
const base::Closure& callback) override {
dbus::MethodCall method_call(
......@@ -401,6 +412,7 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
callback.Run(channel);
}
// TODO(crbug.com/1005511): Deprecate with GetEolStatus().
// Called when a response for GetEolStatus() is received.
void OnGetEolStatus(GetEolStatusCallback callback, dbus::Response* response) {
if (!response) {
......@@ -429,6 +441,31 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
static_cast<update_engine::EndOfLifeStatus>(status));
}
// TODO(crbug.com/1005511): Called when a response for GetStatusAdvanced() is
// received instead of a response from GetEolStatus(). A transition is being
// made to handle the deprecation of GetEolStatus() within update_engine.
void OnGetEolInfo(GetEolInfoCallback callback, dbus::Response* response) {
if (!response) {
LOG(ERROR) << "Failed to request getting eol info.";
std::move(callback).Run(EolInfo());
return;
}
dbus::MessageReader reader(response);
update_engine::StatusResult status;
if (!reader.PopArrayOfBytesAsProto(&status)) {
LOG(ERROR) << "Failed to parse proto from DBus Response.";
std::move(callback).Run(EolInfo());
return;
}
EolInfo eol_info;
eol_info.days_from_epoch = status.eol_date();
VLOG(1) << "Eol date received: " << eol_info.days_from_epoch;
std::move(callback).Run(eol_info);
}
// Called when a response for SetUpdateOverCellularPermission() is received.
void OnSetUpdateOverCellularPermission(const base::Closure& callback,
dbus::Response* response) {
......@@ -585,10 +622,15 @@ class UpdateEngineClientStubImpl : public UpdateEngineClient {
callback.Run(target_channel_);
}
// TODO(crbug.com/1005511): Deprecate with GetEolStatus().
void GetEolStatus(GetEolStatusCallback callback) override {
std::move(callback).Run(update_engine::EndOfLifeStatus::kSupported);
}
void GetEolInfo(GetEolInfoCallback callback) override {
std::move(callback).Run(EolInfo());
}
void SetUpdateOverCellularPermission(bool allowed,
const base::Closure& callback) override {
callback.Run();
......
......@@ -31,6 +31,13 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) UpdateEngineClient : public DBusClient {
UPDATE_RESULT_NOTIMPLEMENTED,
};
// Holds information related to end-of-life.
struct EolInfo {
// The number of days since Unix Epoch, all negative values signify an
// invalid value.
int64_t days_from_epoch = -1;
};
// Interface for observing changes from the update engine.
class Observer {
public:
......@@ -106,14 +113,25 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) UpdateEngineClient : public DBusClient {
virtual void GetChannel(bool get_current_channel,
const GetChannelCallback& callback) = 0;
// TODO(crbug.com/1005511): Deprecate with GetEolStatus().
// Called once GetEolStatus() is complete. Takes one parameter;
// - EndOfLife Status: the end of life status of the device.
using GetEolStatusCallback =
base::OnceCallback<void(update_engine::EndOfLifeStatus status)>;
// TODO(crbug.com/1005511): Deprecate GetEolStatus() use GetEolInfo().
// Get EndOfLife status of the device and calls |callback| when completed.
virtual void GetEolStatus(GetEolStatusCallback callback) = 0;
// Called once GetStatusAdvanced() is complete. Takes one parameter;
// - EolInfo: Please look at EolInfo for param details, all params related to
// end-of-life will be place within this struct.
using GetEolInfoCallback = base::OnceCallback<void(EolInfo eol_info)>;
// Get EndOfLife info for the device and calls |callback| when completed. This
// method should be used in place of GetEolInfo.
virtual void GetEolInfo(GetEolInfoCallback callback) = 0;
// Either allow or disallow receiving updates over cellular connections.
// Synchronous (blocking) method.
virtual void SetUpdateOverCellularPermission(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment