shill: Implement Connect() and Disconnect() for CellularCapabilityUniversal
Refactor such that Cellular::Connect() passes down a callback that can
call On{Connected,Disconnected}{,Failed}(), rather than having
subclasses know about it. This requires overriding
CellularCapabilityClassic::Connect() in
CellularCapabilityGSM so that it can put its APN-handling callback on
the chain; this in turn requires exposing simple_proxy_ to that class.
TEST=Connect and disconnect from UI
BUG=None
Change-Id: I0b504e106ea6f880d40fa452149db34bc60b4f5b
Reviewed-on: https://gerrit.chromium.org/gerrit/20584
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
Commit-Ready: Nathan J. Williams <njw@chromium.org>
Tested-by: Nathan J. Williams <njw@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index 53d537d..3a5bc5a 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -224,6 +224,16 @@
}
}
+void CellularCapabilityGSM::Connect(const DBusPropertiesMap &properties,
+ Error *error,
+ const ResultCallback &callback) {
+ VLOG(2) << __func__;
+ ResultCallback cb = Bind(&CellularCapabilityGSM::OnConnectReply,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback);
+ simple_proxy_->Connect(properties, error, cb, kTimeoutConnect);
+}
+
void CellularCapabilityGSM::OnConnectReply(const ResultCallback &callback,
const Error &error) {
if (error.IsFailure()) {
@@ -246,7 +256,8 @@
cellular()->service()->SetLastGoodApn(apn_try_list_.front());
apn_try_list_.clear();
}
- CellularCapabilityClassic::OnConnectReply(callback, error);
+ if (!callback.is_null())
+ callback.Run(error);
}
bool CellularCapabilityGSM::AllowRoaming() {