Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: chromeos/dbus/update_engine_client.cc

Issue 2694923005: Appropriate handling for Cellular First devices. (Closed)
Patch Set: rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/update_engine_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/update_engine_client.cc
diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc
index d772d0074513b7cbf9ddf6cd6ab55430c37faf95..9f855f0652c91f800d6d6ca8acae4384a2aeee45 100644
--- a/chromeos/dbus/update_engine_client.cc
+++ b/chromeos/dbus/update_engine_client.cc
@@ -218,6 +218,23 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
weak_ptr_factory_.GetWeakPtr(), callback));
}
+ void SetUpdateOverCellularPermission(bool allowed,
+ const base::Closure& callback) override {
+ dbus::MethodCall method_call(
+ update_engine::kUpdateEngineInterface,
+ update_engine::kSetUpdateOverCellularPermission);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendBool(allowed);
+
+ VLOG(1) << "Requesting UpdateEngine to " << (allowed ? "allow" : "prohibit")
+ << " updates over cellular.";
+
+ return update_engine_proxy_->CallMethod(
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&UpdateEngineClientImpl::OnSetUpdateOverCellularPermission,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+ }
+
protected:
void Init(dbus::Bus* bus) override {
update_engine_proxy_ = bus->GetObjectProxy(
@@ -394,6 +411,35 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
callback.Run(static_cast<update_engine::EndOfLifeStatus>(status));
}
+ // Called when a response for SetUpdateOverCellularPermission() is received.
+ void OnSetUpdateOverCellularPermission(const base::Closure& callback,
+ dbus::Response* response) {
+ constexpr char kFailureMessage[] =
+ "Failed to set UpdateEngine to allow updates over cellular: ";
+
+ 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.";
+ break;
+ }
+ } else {
+ LOG(ERROR) << kFailureMessage << "No response from DBus.";
+ }
+
+ // Callback should run anyway, regardless of whether DBus call to enable
+ // update over cellular succeeded or failed.
+ callback.Run();
+ }
+
// Called when a status update signal is received.
void StatusUpdateReceived(dbus::Signal* signal) {
VLOG(1) << "Status update signal received: " << signal->ToString();
@@ -487,6 +533,11 @@ class UpdateEngineClientStubImpl : public UpdateEngineClient {
callback.Run(update_engine::EndOfLifeStatus::kSupported);
}
+ void SetUpdateOverCellularPermission(bool allowed,
+ const base::Closure& callback) override {
+ callback.Run();
+ }
+
std::string current_channel_;
std::string target_channel_;
};
« no previous file with comments | « chromeos/dbus/update_engine_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698