shill: Move the remaining Gsm.Card interfaces to the GSM capability delegate.
This allowed ownership transfer of the Gsm.Card proxy from Cellular to the
delegate.
BUG=chromium-os:18735
TEST=unit tests
Change-Id: I55f56ffb09950002f2d3a50edac5a566cb35d14f
Reviewed-on: https://gerrit.chromium.org/gerrit/11375
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Jason Glasgow <jglasgow@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 464d62b..1862e3e 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -19,17 +19,46 @@
void CellularCapabilityGSM::InitProxies() {
VLOG(2) << __func__;
- // TODO(petkov): Move GSM-specific proxy ownership from Cellular to this.
- cellular()->set_modem_gsm_card_proxy(
- proxy_factory()->CreateModemGSMCardProxy(cellular(),
+ card_proxy_.reset(
+ proxy_factory()->CreateModemGSMCardProxy(this,
cellular()->dbus_path(),
cellular()->dbus_owner()));
+ // TODO(petkov): Move GSM-specific proxy ownership from Cellular to this.
cellular()->set_modem_gsm_network_proxy(
proxy_factory()->CreateModemGSMNetworkProxy(cellular(),
cellular()->dbus_path(),
cellular()->dbus_owner()));
}
+void CellularCapabilityGSM::GetIdentifiers() {
+ VLOG(2) << __func__;
+ 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();
+ }
+ if (cellular()->spn().empty()) {
+ // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
+ try {
+ cellular()->set_spn(card_proxy_->GetSPN());
+ VLOG(2) << "SPN: " << cellular()->spn();
+ } catch (const DBus::Error e) {
+ // Some modems don't support this call so catch the exception explicitly.
+ LOG(WARNING) << "Unable to obtain SPN: " << e.what();
+ }
+ }
+ if (cellular()->mdn().empty()) {
+ // TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
+ cellular()->set_mdn(card_proxy_->GetMSISDN());
+ VLOG(2) << "MSISDN/MDN: " << cellular()->mdn();
+ }
+}
+
void CellularCapabilityGSM::RequirePIN(
const string &pin, bool require, Error */*error*/) {
VLOG(2) << __func__ << "(" << pin << ", " << require << ")";
@@ -42,7 +71,7 @@
void CellularCapabilityGSM::RequirePINTask(const string &pin, bool require) {
VLOG(2) << __func__ << "(" << pin << ", " << require << ")";
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- cellular()->modem_gsm_card_proxy()->EnablePIN(pin, require);
+ card_proxy_->EnablePIN(pin, require);
}
void CellularCapabilityGSM::EnterPIN(const string &pin, Error */*error*/) {
@@ -56,7 +85,7 @@
void CellularCapabilityGSM::EnterPINTask(const string &pin) {
VLOG(2) << __func__ << "(" << pin << ")";
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- cellular()->modem_gsm_card_proxy()->SendPIN(pin);
+ card_proxy_->SendPIN(pin);
}
void CellularCapabilityGSM::UnblockPIN(
@@ -72,7 +101,7 @@
const string &unblock_code, const string &pin) {
VLOG(2) << __func__ << "(" << unblock_code << ", " << pin << ")";
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- cellular()->modem_gsm_card_proxy()->SendPUK(unblock_code, pin);
+ card_proxy_->SendPUK(unblock_code, pin);
}
void CellularCapabilityGSM::ChangePIN(
@@ -88,7 +117,7 @@
const string &old_pin, const string &new_pin) {
VLOG(2) << __func__ << "(" << old_pin << ", " << new_pin << ")";
// TODO(petkov): Switch to asynchronous calls (crosbug.com/17583).
- cellular()->modem_gsm_card_proxy()->ChangePIN(old_pin, new_pin);
+ card_proxy_->ChangePIN(old_pin, new_pin);
}
} // namespace shill