shill: cellular: Obtain IMSI when a GSM device is constructed.

This CL modifies CellularCapabilityGSM to obtain the IMSI value at
construction instead of when the modem is enabled. The IMSI value is
checked by Chrome to determine if a SIM is present before the device can
be enabled.

BUG=chromium-os:31651
TEST=Tested the following:
1. Build and run unit tests.
2. Verify that Gobi and Icera modems can be enabled as follows:
   a. Configure the modem in GSM and insert a SIM with no PIN lock.
   b. Disable the cellular device from UI.
   c. Reboot the Chromebook.
   d. Enable the cellular device from UI and it works.
   e. Repeat with a PIN-locked SIM.
3. Verify that Gobi and Icera modems cannot be enabled as follows:
   a. Configure the modem in GSM with no SIM inserted.
   b. Disable the cellular device from UI.
   c. Reboot the Chromebook.
   d. Enable the cellular device from UI and it does not work.

Change-Id: Iff21f972661cedb383b9a6820fdc7ba3160fd01a
Reviewed-on: https://gerrit.chromium.org/gerrit/29313
Commit-Ready: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/cellular.cc b/cellular.cc
index 32c2ccd..a69eaa2 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -98,7 +98,8 @@
                    const string &owner,
                    const string &service,
                    const string &path,
-                   mobile_provider_db *provider_db)
+                   mobile_provider_db *provider_db,
+                   ProxyFactory *proxy_factory)
     : Device(control_interface,
              dispatcher,
              metrics,
@@ -113,6 +114,7 @@
       dbus_service_(service),
       dbus_path_(path),
       provider_db_(provider_db),
+      proxy_factory_(proxy_factory),
       allow_roaming_(false) {
   PropertyStore *store = this->mutable_store();
   // TODO(jglasgow): kDBusConnectionProperty is deprecated.
@@ -128,7 +130,7 @@
   store->RegisterConstStringmap(flimflam::kHomeProviderProperty,
                                 &home_provider_.ToDict());
   // For now, only a single capability is supported.
-  InitCapability(type, ProxyFactory::GetInstance());
+  InitCapability(type);
 
   SLOG(Cellular, 2) << "Cellular device " << this->link_name()
                     << " initialized.";
@@ -268,19 +270,19 @@
   callback.Run(error);
 }
 
-void Cellular::InitCapability(Type type, ProxyFactory *proxy_factory) {
+void Cellular::InitCapability(Type type) {
   // TODO(petkov): Consider moving capability construction into a factory that's
   // external to the Cellular class.
   SLOG(Cellular, 2) << __func__ << "(" << type << ")";
   switch (type) {
     case kTypeGSM:
-      capability_.reset(new CellularCapabilityGSM(this, proxy_factory));
+      capability_.reset(new CellularCapabilityGSM(this, proxy_factory_));
       break;
     case kTypeCDMA:
-      capability_.reset(new CellularCapabilityCDMA(this, proxy_factory));
+      capability_.reset(new CellularCapabilityCDMA(this, proxy_factory_));
       break;
     case kTypeUniversal:
-      capability_.reset(new CellularCapabilityUniversal(this, proxy_factory));
+      capability_.reset(new CellularCapabilityUniversal(this, proxy_factory_));
       break;
     default: NOTREACHED();
   }