update_engine: Add disconnected network type for metrics reporting

On a failed update, correctly report that the network is disconnected
rather than reporting an "unknown" network type, which is set when the
connection type cannot be determined based on the properties of a given
service path.

BUG=chromium:660283
TEST=Added relevant unittests. Also tested manually by updating via cros
flash, unplugging Ethernet after the transfer, and killing the
dev_server. Metrics sends "disconnected" as expected.

Change-Id: Ia681b769208b67fb5c14d41a646d816a42ccf33e
Reviewed-on: https://chromium-review.googlesource.com/1231700
Commit-Ready: Colin Howes <chowes@google.com>
Tested-by: Colin Howes <chowes@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc
index 85b8c57..7cd858d 100644
--- a/connection_manager_unittest.cc
+++ b/connection_manager_unittest.cc
@@ -75,6 +75,9 @@
       const char* service_type,
       const char* physical_technology,
       ConnectionType expected_type);
+
+  void TestWithServiceDisconnected(ConnectionType expected_type);
+
   void TestWithServiceTethering(
       const char* service_tethering,
       ConnectionTethering expected_tethering);
@@ -170,6 +173,18 @@
       fake_shill_proxy_->GetManagerProxy());
 }
 
+void ConnectionManagerTest::TestWithServiceDisconnected(
+    ConnectionType expected_type) {
+  SetManagerReply("/", true);
+
+  ConnectionType type;
+  ConnectionTethering tethering;
+  EXPECT_TRUE(cmut_.GetConnectionProperties(&type, &tethering));
+  EXPECT_EQ(expected_type, type);
+  testing::Mock::VerifyAndClearExpectations(
+      fake_shill_proxy_->GetManagerProxy());
+}
+
 TEST_F(ConnectionManagerTest, SimpleTest) {
   TestWithServiceType(shill::kTypeEthernet, nullptr, ConnectionType::kEthernet);
   TestWithServiceType(shill::kTypeWifi, nullptr, ConnectionType::kWifi);
@@ -203,6 +218,10 @@
   TestWithServiceType("foo", nullptr, ConnectionType::kUnknown);
 }
 
+TEST_F(ConnectionManagerTest, DisconnectTest) {
+  TestWithServiceDisconnected(ConnectionType::kDisconnected);
+}
+
 TEST_F(ConnectionManagerTest, AllowUpdatesOverEthernetTest) {
   // Updates over Ethernet are allowed even if there's no policy.
   EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,