shill: Do a better job keeping the Service.State property up to date.

For the network settings UI to behave correctly, service state
transitions need to be reflected in the value of the Service.State
property. The goal here is to emulate flimflam's behavior, but this
is not an exact science. The changes in this CL seem to result
in correct UI behavior.

BUG=chromium-os:28472,chromium-os:28538
TEST=Tested manually under as wide a variety of connect and disconnect
scenarios as I could come up with.

Change-Id: I7c8458cceafc228ba579a32631194bff24602e55
Reviewed-on: https://gerrit.chromium.org/gerrit/19395
Commit-Ready: Eric Shienbrood <ers@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Tested-by: Eric Shienbrood <ers@chromium.org>
diff --git a/cellular.cc b/cellular.cc
index 55b9fc0..d7058e6 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -336,6 +336,7 @@
 
   DBusPropertiesMap properties;
   capability_->SetupConnectProperties(&properties);
+  service_->SetState(Service::kStateAssociating);
   // TODO(ers): use null callback until Connect is made fully asynchronous
   capability_->Connect(properties, error, ResultCallback());
 }
@@ -368,11 +369,13 @@
 
 void Cellular::OnDisconnected() {
   VLOG(2) << __func__;
-  if (state_ == kStateConnected || state_ == kStateLinked)
+  if (state_ == kStateConnected || state_ == kStateLinked) {
     SetState(kStateRegistered);
-  else
+    SetServiceFailureSilent(Service::kFailureUnknown);
+  } else {
     LOG(WARNING) << "Disconnect occurred while in state "
                  << GetStateString(state_);
+  }
 }
 
 void Cellular::OnDisconnectFailed() {