shill: Framework for asynchronous service side RPC calls.
Use the framework to switch EnterPIN to return asynchronously.
Also, added a few try/catch clauses around DBus proxy calls to ease testing and
debugging. They should go away as we transition to asynchronous proxy calls.
BUG=chromium-os:17263
TEST=unit tests, tested on device
Change-Id: I4177c5b91e23c31838b03689de729932c859a936
Reviewed-on: https://gerrit.chromium.org/gerrit/12541
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index ac8c1a9..e226f76 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -117,12 +117,15 @@
if (cellular()->imei().empty()) {
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
cellular()->set_imei(card_proxy_->GetIMEI());
- VLOG(2) << "IMEI: " << cellular()->imei();
}
if (cellular()->imsi().empty()) {
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- cellular()->set_imsi(card_proxy_->GetIMSI());
- VLOG(2) << "IMSI: " << cellular()->imsi();
+ try {
+ cellular()->set_imsi(card_proxy_->GetIMSI());
+ VLOG(2) << "IMSI: " << cellular()->imsi();
+ } catch (const DBus::Error e) {
+ LOG(WARNING) << "Unable to obtain IMSI: " << e.what();
+ }
}
if (spn_.empty()) {
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
@@ -332,18 +335,27 @@
card_proxy_->EnablePIN(pin, require);
}
-void CellularCapabilityGSM::EnterPIN(const string &pin, Error */*error*/) {
- VLOG(2) << __func__ << "(" << pin << ")";
+void CellularCapabilityGSM::EnterPIN(const string &pin,
+ ReturnerInterface *returner) {
+ VLOG(2) << __func__ << "(" << returner << ")";
// Defer because we may be in a dbus-c++ callback.
dispatcher()->PostTask(
task_factory_.NewRunnableMethod(
- &CellularCapabilityGSM::EnterPINTask, pin));
+ &CellularCapabilityGSM::EnterPINTask, pin, returner));
}
-void CellularCapabilityGSM::EnterPINTask(const string &pin) {
- VLOG(2) << __func__ << "(" << pin << ")";
+void CellularCapabilityGSM::EnterPINTask(const string &pin,
+ ReturnerInterface *returner) {
+ VLOG(2) << __func__ << "(" << returner << ")";
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- card_proxy_->SendPIN(pin);
+ try {
+ card_proxy_->SendPIN(pin);
+ } catch (DBus::Error e) {
+ LOG(ERROR) << "EnterPIN failed: " << e.name() << "/" << e.message();
+ returner->ReturnError(Error(Error::kInternalError));
+ return;
+ }
+ returner->Return();
}
void CellularCapabilityGSM::UnblockPIN(