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.cc b/cellular.cc
index 4b3d399..55675dc 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -240,7 +240,7 @@
 void Cellular::OnModemStarted(const EnabledStateChangedCallback &callback,
                               const Error &error) {
   SLOG(Cellular, 2) << __func__ << ": " << GetStateString(state_);
-  if (state_ == kStateDisabled) {
+  if (error.IsSuccess() && (state_ == kStateDisabled)) {
     SetState(kStateEnabled);
     // Registration state updates may have been ignored while the
     // modem was not yet marked enabled.