| Index: chromeos/dbus/update_engine_client.cc
|
| diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc
|
| index 5cfe397658f2b6f07b6696303b0d52388f6eb3f9..b10d67c0fd07050ae11d59c433a8e7d48cf20bf8 100644
|
| --- a/chromeos/dbus/update_engine_client.cc
|
| +++ b/chromeos/dbus/update_engine_client.cc
|
| @@ -69,6 +69,8 @@ UpdateEngineClient::UpdateStatusOperation UpdateStatusFromString(
|
| return UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT;
|
| if (str == update_engine::kUpdateStatusAttemptingRollback)
|
| return UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK;
|
| + if (str == update_engine::kUpdateStatusNeedPermissionToUpdate)
|
| + return UpdateEngineClient::UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE;
|
| return UpdateEngineClient::UPDATE_STATUS_ERROR;
|
| }
|
|
|
| @@ -245,6 +247,25 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
|
| weak_ptr_factory_.GetWeakPtr(), callback));
|
| }
|
|
|
| + void SetUpdateOverCellularTarget(const std::string& target_version,
|
| + int64_t target_size,
|
| + const SetTargetCallback& callback) override {
|
| + dbus::MethodCall method_call(update_engine::kUpdateEngineInterface,
|
| + update_engine::kSetUpdateOverCellularTarget);
|
| + dbus::MessageWriter writer(&method_call);
|
| + writer.AppendString(target_version);
|
| + writer.AppendInt64(target_size);
|
| +
|
| + VLOG(1) << "Requesting UpdateEngine to allow updates over cellular "
|
| + << "to target version: \"" << target_version << "\" "
|
| + << "target_size: " << target_size;
|
| +
|
| + return update_engine_proxy_->CallMethod(
|
| + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
|
| + base::Bind(&UpdateEngineClientImpl::OnSetUpdateOverCellularTarget,
|
| + weak_ptr_factory_.GetWeakPtr(), callback));
|
| + }
|
| +
|
| protected:
|
| void Init(dbus::Bus* bus) override {
|
| update_engine_proxy_ = bus->GetObjectProxy(
|
| @@ -458,6 +479,35 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
|
| callback.Run();
|
| }
|
|
|
| + // Called when a response for SetUpdateOverCellularPermission() is received.
|
| + void OnSetUpdateOverCellularTarget(const SetTargetCallback& callback,
|
| + dbus::Response* response) {
|
| + constexpr char kFailureMessage[] =
|
| + "Failed to set UpdateEngine to allow updates over cellular to a given "
|
| + "target: ";
|
| +
|
| + if (response) {
|
| + switch (response->GetMessageType()) {
|
| + case dbus::Message::MESSAGE_ERROR:
|
| + LOG(ERROR) << kFailureMessage
|
| + << "DBus responded with error: " << response->ToString();
|
| + break;
|
| + case dbus::Message::MESSAGE_INVALID:
|
| + LOG(ERROR) << kFailureMessage
|
| + << "Invalid response from DBus (cannot be parsed).";
|
| + break;
|
| + default:
|
| + VLOG(1) << "Successfully set UpdateEngine to allow update over cell "
|
| + "to a given target.";
|
| + callback.Run(true);
|
| + return;
|
| + }
|
| + } else {
|
| + LOG(ERROR) << kFailureMessage << "No response from DBus.";
|
| + }
|
| + callback.Run(false);
|
| + }
|
| +
|
| // Called when a status update signal is received.
|
| void StatusUpdateReceived(dbus::Signal* signal) {
|
| VLOG(1) << "Status update signal received: " << signal->ToString();
|
| @@ -562,6 +612,11 @@ class UpdateEngineClientStubImpl : public UpdateEngineClient {
|
| const base::Closure& callback) override {
|
| callback.Run();
|
| }
|
| + void SetUpdateOverCellularTarget(const std::string& target_version,
|
| + int64_t target_size,
|
| + const SetTargetCallback& callback) override {
|
| + // Do nothing.
|
| + }
|
|
|
| std::string current_channel_;
|
| std::string target_channel_;
|
| @@ -619,6 +674,7 @@ class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl {
|
| case UPDATE_STATUS_UPDATED_NEED_REBOOT:
|
| case UPDATE_STATUS_REPORTING_ERROR_EVENT:
|
| case UPDATE_STATUS_ATTEMPTING_ROLLBACK:
|
| + case UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE:
|
| return;
|
| case UPDATE_STATUS_CHECKING_FOR_UPDATE:
|
| next_status = UPDATE_STATUS_UPDATE_AVAILABLE;
|
|
|