shill: Fix cellular PIN unlock

There were three problems.  1) The properties of the modem were not
being parsed when the modem was first started, and so the lock status
of the modem was not known, which prevented the GUI from asking the
user to enter a PIN. 2) When the modem is locked, it cannot be
started successfully, but the software state of the modem was being
changed to "enabled", preventing it from being enabled when the PIN
was entered (you can't enable an already enabled modem).  3) When
enabling a modem failed, the asynchronous enable function still
thought the enable operation was in progress, preventing the
enabling of the modem once the PIN is entered.

BUG=chromium-os:29847
TEST=manual.  Try to enable a PIN-locked GSM modem.  Also added new
unittests.

Change-Id: I72258586c3ba59abbcc40e03b47d4b7b9e4b73da
Reviewed-on: https://gerrit.chromium.org/gerrit/21562
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
Commit-Ready: Gary Morain <gmorain@chromium.org>
Tested-by: Gary Morain <gmorain@chromium.org>
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index fbc1884..6042415 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -781,21 +781,24 @@
                                   &access_technology)) {
       SetAccessTechnology(access_technology);
     }
-  } else if (interface == MM_MODEM_GSM_CARD_INTERFACE) {
+  } else {
     bool emit = false;
-    uint32 locks = 0;
-    if (DBusProperties::GetUint32(
-        properties, kPropertyEnabledFacilityLocks, &locks)) {
-      sim_lock_status_.enabled = locks & MM_MODEM_GSM_FACILITY_SIM;
-      emit = true;
-    }
-    if (DBusProperties::GetString(
-        properties, kPropertyUnlockRequired, &sim_lock_status_.lock_type)) {
-      emit = true;
-    }
-    if (DBusProperties::GetUint32(
-        properties, kPropertyUnlockRetries, &sim_lock_status_.retries_left)) {
-      emit = true;
+    if (interface == MM_MODEM_GSM_CARD_INTERFACE) {
+      uint32 locks = 0;
+      if (DBusProperties::GetUint32(
+              properties, kPropertyEnabledFacilityLocks, &locks)) {
+        sim_lock_status_.enabled = locks & MM_MODEM_GSM_FACILITY_SIM;
+        emit = true;
+      }
+    } else if (interface == MM_MODEM_INTERFACE) {
+      if (DBusProperties::GetString(properties, kPropertyUnlockRequired,
+                                    &sim_lock_status_.lock_type)) {
+        emit = true;
+      }
+      if (DBusProperties::GetUint32(properties, kPropertyUnlockRetries,
+                                    &sim_lock_status_.retries_left)) {
+        emit = true;
+      }
     }
     if (emit) {
       cellular()->adaptor()->EmitKeyValueStoreChanged(