Move ParseConnection*() to connection_utils.

We don't need real_shill_provider if USE_DBUS is 0, but we still need
these functions, and they have a duplicate copy in connection_manager,
so put them in utils and deduplicate.

Also moved StringForConnectionType() to connection_utils.

Bug: 28800946
Test: mma

Change-Id: If535fdc52bc8fb267921bea02b31d8d6580d5d54
diff --git a/Android.mk b/Android.mk
index a44e908..97b9f7a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -307,6 +307,7 @@
     boot_control_android.cc \
     common_service.cc \
     connection_manager.cc \
+    connection_utils.cc \
     daemon.cc \
     dbus_service.cc \
     hardware_android.cc \
diff --git a/common_service.cc b/common_service.cc
index ade5349..e284a93 100644
--- a/common_service.cc
+++ b/common_service.cc
@@ -273,9 +273,8 @@
   // Return the current setting based on the same logic used while checking for
   // updates. A log message could be printed as the result of this test.
   LOG(INFO) << "Checking if updates over cellular networks are allowed:";
-  *out_allowed = cm->IsUpdateAllowedOver(
-      chromeos_update_engine::NetworkConnectionType::kCellular,
-      chromeos_update_engine::NetworkTethering::kUnknown);
+  *out_allowed = cm->IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown);
   return true;
 }
 
diff --git a/connection_manager.cc b/connection_manager.cc
index 778cba5..13503d9 100644
--- a/connection_manager.cc
+++ b/connection_manager.cc
@@ -27,6 +27,7 @@
 
 #include "update_engine/common/prefs.h"
 #include "update_engine/common/utils.h"
+#include "update_engine/connection_utils.h"
 #include "update_engine/system_state.h"
 
 using org::chromium::flimflam::ManagerProxyInterface;
@@ -36,48 +37,17 @@
 
 namespace chromeos_update_engine {
 
-namespace {
-
-NetworkConnectionType ParseConnectionType(const string& type_str) {
-  if (type_str == shill::kTypeEthernet) {
-    return NetworkConnectionType::kEthernet;
-  } else if (type_str == shill::kTypeWifi) {
-    return NetworkConnectionType::kWifi;
-  } else if (type_str == shill::kTypeWimax) {
-    return NetworkConnectionType::kWimax;
-  } else if (type_str == shill::kTypeBluetooth) {
-    return NetworkConnectionType::kBluetooth;
-  } else if (type_str == shill::kTypeCellular) {
-    return NetworkConnectionType::kCellular;
-  }
-  return NetworkConnectionType::kUnknown;
-}
-
-NetworkTethering ParseTethering(const string& tethering_str) {
-  if (tethering_str == shill::kTetheringNotDetectedState) {
-    return NetworkTethering::kNotDetected;
-  } else if (tethering_str == shill::kTetheringSuspectedState) {
-    return NetworkTethering::kSuspected;
-  } else if (tethering_str == shill::kTetheringConfirmedState) {
-    return NetworkTethering::kConfirmed;
-  }
-  LOG(WARNING) << "Unknown Tethering value: " << tethering_str;
-  return NetworkTethering::kUnknown;
-}
-
-}  // namespace
-
 ConnectionManager::ConnectionManager(ShillProxyInterface* shill_proxy,
                                      SystemState* system_state)
     : shill_proxy_(shill_proxy), system_state_(system_state) {}
 
-bool ConnectionManager::IsUpdateAllowedOver(NetworkConnectionType type,
-                                            NetworkTethering tethering) const {
+bool ConnectionManager::IsUpdateAllowedOver(
+    ConnectionType type, ConnectionTethering tethering) const {
   switch (type) {
-    case NetworkConnectionType::kBluetooth:
+    case ConnectionType::kBluetooth:
       return false;
 
-    case NetworkConnectionType::kCellular: {
+    case ConnectionType::kCellular: {
       set<string> allowed_types;
       const policy::DevicePolicy* device_policy =
           system_state_->device_policy();
@@ -130,40 +100,19 @@
     }
 
     default:
-      if (tethering == NetworkTethering::kConfirmed) {
+      if (tethering == ConnectionTethering::kConfirmed) {
         // Treat this connection as if it is a cellular connection.
         LOG(INFO) << "Current connection is confirmed tethered, using Cellular "
                      "setting.";
-        return IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                   NetworkTethering::kUnknown);
+        return IsUpdateAllowedOver(ConnectionType::kCellular,
+                                   ConnectionTethering::kUnknown);
       }
       return true;
   }
 }
 
-// static
-const char* ConnectionManager::StringForConnectionType(
-    NetworkConnectionType type) {
-  switch (type) {
-    case NetworkConnectionType::kEthernet:
-      return shill::kTypeEthernet;
-    case NetworkConnectionType::kWifi:
-      return shill::kTypeWifi;
-    case NetworkConnectionType::kWimax:
-      return shill::kTypeWimax;
-    case NetworkConnectionType::kBluetooth:
-      return shill::kTypeBluetooth;
-    case NetworkConnectionType::kCellular:
-      return shill::kTypeCellular;
-    case NetworkConnectionType::kUnknown:
-      return "Unknown";
-  }
-  return "Unknown";
-}
-
 bool ConnectionManager::GetConnectionProperties(
-    NetworkConnectionType* out_type,
-    NetworkTethering* out_tethering) {
+    ConnectionType* out_type, ConnectionTethering* out_tethering) {
   dbus::ObjectPath default_service_path;
   TEST_AND_RETURN_FALSE(GetDefaultServicePath(&default_service_path));
   if (!default_service_path.IsValid())
@@ -195,8 +144,8 @@
 
 bool ConnectionManager::GetServicePathProperties(
     const dbus::ObjectPath& path,
-    NetworkConnectionType* out_type,
-    NetworkTethering* out_tethering) {
+    ConnectionType* out_type,
+    ConnectionTethering* out_tethering) {
   // We create and dispose the ServiceProxyInterface on every request.
   std::unique_ptr<ServiceProxyInterface> service =
       shill_proxy_->GetServiceForPath(path);
@@ -209,18 +158,19 @@
   const auto& prop_tethering = properties.find(shill::kTetheringProperty);
   if (prop_tethering == properties.end()) {
     // Set to Unknown if not present.
-    *out_tethering = NetworkTethering::kUnknown;
+    *out_tethering = ConnectionTethering::kUnknown;
   } else {
     // If the property doesn't contain a string value, the empty string will
     // become kUnknown.
-    *out_tethering = ParseTethering(prop_tethering->second.TryGet<string>());
+    *out_tethering = connection_utils::ParseConnectionTethering(
+        prop_tethering->second.TryGet<string>());
   }
 
   // Populate the out_type property.
   const auto& prop_type = properties.find(shill::kTypeProperty);
   if (prop_type == properties.end()) {
     // Set to Unknown if not present.
-    *out_type = NetworkConnectionType::kUnknown;
+    *out_type = ConnectionType::kUnknown;
     return false;
   }
 
@@ -232,12 +182,13 @@
       LOG(ERROR) << "No PhysicalTechnology property found for a VPN"
                     " connection (service: "
                  << path.value() << "). Returning default kUnknown value.";
-      *out_type = NetworkConnectionType::kUnknown;
+      *out_type = ConnectionType::kUnknown;
     } else {
-      *out_type = ParseConnectionType(prop_physical->second.TryGet<string>());
+      *out_type = connection_utils::ParseConnectionType(
+          prop_physical->second.TryGet<string>());
     }
   } else {
-    *out_type = ParseConnectionType(type_str);
+    *out_type = connection_utils::ParseConnectionType(type_str);
   }
   return true;
 }
diff --git a/connection_manager.h b/connection_manager.h
index 2057f3b..1143f83 100644
--- a/connection_manager.h
+++ b/connection_manager.h
@@ -34,10 +34,6 @@
 // TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
 class ConnectionManager : public ConnectionManagerInterface {
  public:
-  // Returns the string representation corresponding to the given
-  // connection type.
-  static const char* StringForConnectionType(NetworkConnectionType type);
-
   // Constructs a new ConnectionManager object initialized with the
   // given system state.
   ConnectionManager(ShillProxyInterface* shill_proxy,
@@ -45,10 +41,10 @@
   ~ConnectionManager() override = default;
 
   // ConnectionManagerInterface overrides.
-  bool GetConnectionProperties(NetworkConnectionType* out_type,
-                               NetworkTethering* out_tethering) override;
-  bool IsUpdateAllowedOver(NetworkConnectionType type,
-                           NetworkTethering tethering) const override;
+  bool GetConnectionProperties(ConnectionType* out_type,
+                               ConnectionTethering* out_tethering) override;
+  bool IsUpdateAllowedOver(ConnectionType type,
+                           ConnectionTethering tethering) const override;
 
  private:
   // Returns (via out_path) the default network path, or empty string if
@@ -56,8 +52,8 @@
   bool GetDefaultServicePath(dbus::ObjectPath* out_path);
 
   bool GetServicePathProperties(const dbus::ObjectPath& path,
-                                NetworkConnectionType* out_type,
-                                NetworkTethering* out_tethering);
+                                ConnectionType* out_type,
+                                ConnectionTethering* out_tethering);
 
   // The mockable interface to access the shill DBus proxies.
   ShillProxyInterface* shill_proxy_;
diff --git a/connection_manager_interface.h b/connection_manager_interface.h
index cb60a3c..d36ef76 100644
--- a/connection_manager_interface.h
+++ b/connection_manager_interface.h
@@ -19,24 +19,10 @@
 
 #include <base/macros.h>
 
+#include "update_engine/connection_utils.h"
+
 namespace chromeos_update_engine {
 
-enum class NetworkConnectionType {
-  kEthernet,
-  kWifi,
-  kWimax,
-  kBluetooth,
-  kCellular,
-  kUnknown
-};
-
-enum class NetworkTethering {
-  kNotDetected,
-  kSuspected,
-  kConfirmed,
-  kUnknown
-};
-
 // This class exposes a generic interface to the connection manager
 // (e.g FlimFlam, Shill, etc.) to consolidate all connection-related
 // logic in update_engine.
@@ -47,14 +33,14 @@
   // Populates |out_type| with the type of the network connection
   // that we are currently connected and |out_tethering| with the estimate of
   // whether that network is being tethered.
-  virtual bool GetConnectionProperties(NetworkConnectionType* out_type,
-                                       NetworkTethering* out_tethering) = 0;
+  virtual bool GetConnectionProperties(ConnectionType* out_type,
+                                       ConnectionTethering* out_tethering) = 0;
 
   // Returns true if we're allowed to update the system when we're
   // connected to the internet through the given network connection type and the
   // given tethering state.
-  virtual bool IsUpdateAllowedOver(NetworkConnectionType type,
-                                   NetworkTethering tethering) const = 0;
+  virtual bool IsUpdateAllowedOver(ConnectionType type,
+                                   ConnectionTethering tethering) const = 0;
 
  protected:
   ConnectionManagerInterface() = default;
diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc
index 612929b..48f6195 100644
--- a/connection_manager_unittest.cc
+++ b/connection_manager_unittest.cc
@@ -34,6 +34,7 @@
 #include "update_engine/fake_shill_proxy.h"
 #include "update_engine/fake_system_state.h"
 
+using chromeos_update_engine::connection_utils::StringForConnectionType;
 using org::chromium::flimflam::ManagerProxyMock;
 using org::chromium::flimflam::ServiceProxyMock;
 using std::set;
@@ -70,10 +71,10 @@
   void TestWithServiceType(
       const char* service_type,
       const char* physical_technology,
-      NetworkConnectionType expected_type);
+      ConnectionType expected_type);
   void TestWithServiceTethering(
       const char* service_tethering,
-      NetworkTethering expected_tethering);
+      ConnectionTethering expected_tethering);
 
   brillo::FakeMessageLoop loop_{nullptr};
   FakeSystemState fake_system_state_;
@@ -136,15 +137,15 @@
 void ConnectionManagerTest::TestWithServiceType(
     const char* service_type,
     const char* physical_technology,
-    NetworkConnectionType expected_type) {
+    ConnectionType expected_type) {
   SetManagerReply("/service/guest/network", true);
   SetServiceReply("/service/guest/network",
                   service_type,
                   physical_technology,
                   shill::kTetheringNotDetectedState);
 
-  NetworkConnectionType type;
-  NetworkTethering tethering;
+  ConnectionType type;
+  ConnectionTethering tethering;
   EXPECT_TRUE(cmut_.GetConnectionProperties(&type, &tethering));
   EXPECT_EQ(expected_type, type);
   testing::Mock::VerifyAndClearExpectations(
@@ -153,13 +154,13 @@
 
 void ConnectionManagerTest::TestWithServiceTethering(
     const char* service_tethering,
-    NetworkTethering expected_tethering) {
+    ConnectionTethering expected_tethering) {
   SetManagerReply("/service/guest/network", true);
   SetServiceReply(
       "/service/guest/network", shill::kTypeWifi, nullptr, service_tethering);
 
-  NetworkConnectionType type;
-  NetworkTethering tethering;
+  ConnectionType type;
+  ConnectionTethering tethering;
   EXPECT_TRUE(cmut_.GetConnectionProperties(&type, &tethering));
   EXPECT_EQ(expected_tethering, tethering);
   testing::Mock::VerifyAndClearExpectations(
@@ -167,63 +168,57 @@
 }
 
 TEST_F(ConnectionManagerTest, SimpleTest) {
-  TestWithServiceType(shill::kTypeEthernet, nullptr,
-                      NetworkConnectionType::kEthernet);
-  TestWithServiceType(shill::kTypeWifi, nullptr,
-                      NetworkConnectionType::kWifi);
-  TestWithServiceType(shill::kTypeWimax, nullptr,
-                      NetworkConnectionType::kWimax);
-  TestWithServiceType(shill::kTypeBluetooth, nullptr,
-                      NetworkConnectionType::kBluetooth);
-  TestWithServiceType(shill::kTypeCellular, nullptr,
-                      NetworkConnectionType::kCellular);
+  TestWithServiceType(shill::kTypeEthernet, nullptr, ConnectionType::kEthernet);
+  TestWithServiceType(shill::kTypeWifi, nullptr, ConnectionType::kWifi);
+  TestWithServiceType(shill::kTypeWimax, nullptr, ConnectionType::kWimax);
+  TestWithServiceType(
+      shill::kTypeBluetooth, nullptr, ConnectionType::kBluetooth);
+  TestWithServiceType(shill::kTypeCellular, nullptr, ConnectionType::kCellular);
 }
 
 TEST_F(ConnectionManagerTest, PhysicalTechnologyTest) {
-  TestWithServiceType(shill::kTypeVPN, nullptr,
-                      NetworkConnectionType::kUnknown);
-  TestWithServiceType(shill::kTypeVPN, shill::kTypeVPN,
-                      NetworkConnectionType::kUnknown);
-  TestWithServiceType(shill::kTypeVPN, shill::kTypeWifi,
-                      NetworkConnectionType::kWifi);
-  TestWithServiceType(shill::kTypeVPN, shill::kTypeWimax,
-                      NetworkConnectionType::kWimax);
+  TestWithServiceType(shill::kTypeVPN, nullptr, ConnectionType::kUnknown);
+  TestWithServiceType(
+      shill::kTypeVPN, shill::kTypeVPN, ConnectionType::kUnknown);
+  TestWithServiceType(shill::kTypeVPN, shill::kTypeWifi, ConnectionType::kWifi);
+  TestWithServiceType(
+      shill::kTypeVPN, shill::kTypeWimax, ConnectionType::kWimax);
 }
 
 TEST_F(ConnectionManagerTest, TetheringTest) {
   TestWithServiceTethering(shill::kTetheringConfirmedState,
-                           NetworkTethering::kConfirmed);
+                           ConnectionTethering::kConfirmed);
   TestWithServiceTethering(shill::kTetheringNotDetectedState,
-                           NetworkTethering::kNotDetected);
+                           ConnectionTethering::kNotDetected);
   TestWithServiceTethering(shill::kTetheringSuspectedState,
-                           NetworkTethering::kSuspected);
+                           ConnectionTethering::kSuspected);
   TestWithServiceTethering("I'm not a valid property value =)",
-                           NetworkTethering::kUnknown);
+                           ConnectionTethering::kUnknown);
 }
 
 TEST_F(ConnectionManagerTest, UnknownTest) {
-  TestWithServiceType("foo", nullptr, NetworkConnectionType::kUnknown);
+  TestWithServiceType("foo", nullptr, ConnectionType::kUnknown);
 }
 
 TEST_F(ConnectionManagerTest, AllowUpdatesOverEthernetTest) {
   // Updates over Ethernet are allowed even if there's no policy.
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kEthernet,
-                                        NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,
+                                        ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, AllowUpdatesOverWifiTest) {
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWifi,
-                                        NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWifi,
+                                        ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, AllowUpdatesOverWimaxTest) {
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWimax,
-                                        NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWimax,
+                                        ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, BlockUpdatesOverBluetoothTest) {
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kBluetooth,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kBluetooth,
+                                         ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, AllowUpdatesOnlyOver3GPerPolicyTest) {
@@ -233,15 +228,14 @@
 
   // This test tests cellular (3G) being the only connection type being allowed.
   set<string> allowed_set;
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kCellular));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kCellular));
 
   EXPECT_CALL(allow_3g_policy, GetAllowedConnectionTypesForUpdate(_))
       .Times(1)
       .WillOnce(DoAll(SetArgPointee<0>(allowed_set), Return(true)));
 
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                        NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                        ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, AllowUpdatesOver3GAndOtherTypesPerPolicyTest) {
@@ -253,48 +247,46 @@
   // 3G one among them. Only Cellular is currently enforced by the policy
   // setting, the others are ignored (see Bluetooth for example).
   set<string> allowed_set;
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kCellular));
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kBluetooth));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kCellular));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kBluetooth));
 
   EXPECT_CALL(allow_3g_policy, GetAllowedConnectionTypesForUpdate(_))
       .Times(3)
       .WillRepeatedly(DoAll(SetArgPointee<0>(allowed_set), Return(true)));
 
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kEthernet,
-                                        NetworkTethering::kUnknown));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kEthernet,
-                                        NetworkTethering::kNotDetected));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                        NetworkTethering::kUnknown));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWifi,
-                                        NetworkTethering::kUnknown));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWimax,
-                                        NetworkTethering::kUnknown));
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kBluetooth,
-                                         NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,
+                                        ConnectionTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,
+                                        ConnectionTethering::kNotDetected));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                        ConnectionTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWifi,
+                                        ConnectionTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWimax,
+                                        ConnectionTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kBluetooth,
+                                         ConnectionTethering::kUnknown));
 
   // Tethered networks are treated in the same way as Cellular networks and
   // thus allowed.
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kEthernet,
-                                        NetworkTethering::kConfirmed));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWifi,
-                                        NetworkTethering::kConfirmed));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,
+                                        ConnectionTethering::kConfirmed));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWifi,
+                                        ConnectionTethering::kConfirmed));
 }
 
 TEST_F(ConnectionManagerTest, BlockUpdatesOverCellularByDefaultTest) {
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, BlockUpdatesOverTetheredNetworkByDefaultTest) {
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWifi,
-                                         NetworkTethering::kConfirmed));
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kEthernet,
-                                         NetworkTethering::kConfirmed));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kWifi,
-                                        NetworkTethering::kSuspected));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kWifi,
+                                         ConnectionTethering::kConfirmed));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kEthernet,
+                                         ConnectionTethering::kConfirmed));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kWifi,
+                                        ConnectionTethering::kSuspected));
 }
 
 TEST_F(ConnectionManagerTest, BlockUpdatesOver3GPerPolicyTest) {
@@ -305,19 +297,16 @@
   // Test that updates for 3G are blocked while updates are allowed
   // over several other types.
   set<string> allowed_set;
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kEthernet));
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kWifi));
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kWimax));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kEthernet));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kWifi));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kWimax));
 
   EXPECT_CALL(block_3g_policy, GetAllowedConnectionTypesForUpdate(_))
       .Times(1)
       .WillOnce(DoAll(SetArgPointee<0>(allowed_set), Return(true)));
 
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, BlockUpdatesOver3GIfErrorInPolicyFetchTest) {
@@ -326,8 +315,7 @@
   fake_system_state_.set_device_policy(&allow_3g_policy);
 
   set<string> allowed_set;
-  allowed_set.insert(
-      cmut_.StringForConnectionType(NetworkConnectionType::kCellular));
+  allowed_set.insert(StringForConnectionType(ConnectionType::kCellular));
 
   // Return false for GetAllowedConnectionTypesForUpdate and see
   // that updates are still blocked for 3G despite the value being in
@@ -336,8 +324,8 @@
       .Times(1)
       .WillOnce(DoAll(SetArgPointee<0>(allowed_set), Return(false)));
 
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, UseUserPrefForUpdatesOverCellularIfNoPolicyTest) {
@@ -355,8 +343,8 @@
   EXPECT_CALL(*prefs, Exists(kPrefsUpdateOverCellularPermission))
       .Times(1)
       .WillOnce(Return(false));
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown));
 
   // Allow per user pref.
   EXPECT_CALL(*prefs, Exists(kPrefsUpdateOverCellularPermission))
@@ -365,8 +353,8 @@
   EXPECT_CALL(*prefs, GetBoolean(kPrefsUpdateOverCellularPermission, _))
       .Times(1)
       .WillOnce(DoAll(SetArgPointee<1>(true), Return(true)));
-  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                        NetworkTethering::kUnknown));
+  EXPECT_TRUE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                        ConnectionTethering::kUnknown));
 
   // Block per user pref.
   EXPECT_CALL(*prefs, Exists(kPrefsUpdateOverCellularPermission))
@@ -375,34 +363,31 @@
   EXPECT_CALL(*prefs, GetBoolean(kPrefsUpdateOverCellularPermission, _))
       .Times(1)
       .WillOnce(DoAll(SetArgPointee<1>(false), Return(true)));
-  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(NetworkConnectionType::kCellular,
-                                         NetworkTethering::kUnknown));
+  EXPECT_FALSE(cmut_.IsUpdateAllowedOver(ConnectionType::kCellular,
+                                         ConnectionTethering::kUnknown));
 }
 
 TEST_F(ConnectionManagerTest, StringForConnectionTypeTest) {
   EXPECT_STREQ(shill::kTypeEthernet,
-               cmut_.StringForConnectionType(NetworkConnectionType::kEthernet));
+               StringForConnectionType(ConnectionType::kEthernet));
   EXPECT_STREQ(shill::kTypeWifi,
-               cmut_.StringForConnectionType(NetworkConnectionType::kWifi));
+               StringForConnectionType(ConnectionType::kWifi));
   EXPECT_STREQ(shill::kTypeWimax,
-               cmut_.StringForConnectionType(NetworkConnectionType::kWimax));
+               StringForConnectionType(ConnectionType::kWimax));
   EXPECT_STREQ(shill::kTypeBluetooth,
-               cmut_.StringForConnectionType(
-                   NetworkConnectionType::kBluetooth));
+               StringForConnectionType(ConnectionType::kBluetooth));
   EXPECT_STREQ(shill::kTypeCellular,
-               cmut_.StringForConnectionType(NetworkConnectionType::kCellular));
+               StringForConnectionType(ConnectionType::kCellular));
+  EXPECT_STREQ("Unknown", StringForConnectionType(ConnectionType::kUnknown));
   EXPECT_STREQ("Unknown",
-               cmut_.StringForConnectionType(NetworkConnectionType::kUnknown));
-  EXPECT_STREQ("Unknown",
-               cmut_.StringForConnectionType(
-                   static_cast<NetworkConnectionType>(999999)));
+               StringForConnectionType(static_cast<ConnectionType>(999999)));
 }
 
 TEST_F(ConnectionManagerTest, MalformedServiceList) {
   SetManagerReply("/service/guest/network", false);
 
-  NetworkConnectionType type;
-  NetworkTethering tethering;
+  ConnectionType type;
+  ConnectionTethering tethering;
   EXPECT_FALSE(cmut_.GetConnectionProperties(&type, &tethering));
 }
 
diff --git a/connection_utils.cc b/connection_utils.cc
new file mode 100644
index 0000000..9b6b526
--- /dev/null
+++ b/connection_utils.cc
@@ -0,0 +1,70 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/connection_utils.h"
+
+#include <shill/dbus-constants.h>
+
+namespace chromeos_update_engine {
+namespace connection_utils {
+
+ConnectionType ParseConnectionType(const std::string& type_str) {
+  if (type_str == shill::kTypeEthernet) {
+    return ConnectionType::kEthernet;
+  } else if (type_str == shill::kTypeWifi) {
+    return ConnectionType::kWifi;
+  } else if (type_str == shill::kTypeWimax) {
+    return ConnectionType::kWimax;
+  } else if (type_str == shill::kTypeBluetooth) {
+    return ConnectionType::kBluetooth;
+  } else if (type_str == shill::kTypeCellular) {
+    return ConnectionType::kCellular;
+  }
+  return ConnectionType::kUnknown;
+}
+
+ConnectionTethering ParseConnectionTethering(const std::string& tethering_str) {
+  if (tethering_str == shill::kTetheringNotDetectedState) {
+    return ConnectionTethering::kNotDetected;
+  } else if (tethering_str == shill::kTetheringSuspectedState) {
+    return ConnectionTethering::kSuspected;
+  } else if (tethering_str == shill::kTetheringConfirmedState) {
+    return ConnectionTethering::kConfirmed;
+  }
+  return ConnectionTethering::kUnknown;
+}
+
+const char* StringForConnectionType(ConnectionType type) {
+  switch (type) {
+    case ConnectionType::kEthernet:
+      return shill::kTypeEthernet;
+    case ConnectionType::kWifi:
+      return shill::kTypeWifi;
+    case ConnectionType::kWimax:
+      return shill::kTypeWimax;
+    case ConnectionType::kBluetooth:
+      return shill::kTypeBluetooth;
+    case ConnectionType::kCellular:
+      return shill::kTypeCellular;
+    case ConnectionType::kUnknown:
+      return "Unknown";
+  }
+  return "Unknown";
+}
+
+}  // namespace connection_utils
+
+}  // namespace chromeos_update_engine
diff --git a/connection_utils.h b/connection_utils.h
new file mode 100644
index 0000000..e385517
--- /dev/null
+++ b/connection_utils.h
@@ -0,0 +1,51 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef UPDATE_ENGINE_CONNECTION_UTILS_H_
+#define UPDATE_ENGINE_CONNECTION_UTILS_H_
+
+#include <string>
+
+namespace chromeos_update_engine {
+
+enum class ConnectionType {
+  kEthernet,
+  kWifi,
+  kWimax,
+  kBluetooth,
+  kCellular,
+  kUnknown
+};
+
+enum class ConnectionTethering {
+  kNotDetected,
+  kSuspected,
+  kConfirmed,
+  kUnknown,
+};
+
+namespace connection_utils {
+// Helper methods for converting shill strings into symbolic values.
+ConnectionType ParseConnectionType(const std::string& type_str);
+ConnectionTethering ParseConnectionTethering(const std::string& tethering_str);
+
+// Returns the string representation corresponding to the given connection type.
+const char* StringForConnectionType(ConnectionType type);
+}  // namespace connection_utils
+
+}  // namespace chromeos_update_engine
+
+#endif  // UPDATE_ENGINE_CONNECTION_UTILS_H_
diff --git a/metrics_utils.cc b/metrics_utils.cc
index e165e89..263bacd 100644
--- a/metrics_utils.cc
+++ b/metrics_utils.cc
@@ -228,31 +228,31 @@
   return metrics::DownloadErrorCode::kInputMalformed;
 }
 
-metrics::ConnectionType GetConnectionType(NetworkConnectionType type,
-                                          NetworkTethering tethering) {
+metrics::ConnectionType GetConnectionType(ConnectionType type,
+                                          ConnectionTethering tethering) {
   switch (type) {
-    case NetworkConnectionType::kUnknown:
+    case ConnectionType::kUnknown:
       return metrics::ConnectionType::kUnknown;
 
-    case NetworkConnectionType::kEthernet:
-      if (tethering == NetworkTethering::kConfirmed)
+    case ConnectionType::kEthernet:
+      if (tethering == ConnectionTethering::kConfirmed)
         return metrics::ConnectionType::kTetheredEthernet;
       else
         return metrics::ConnectionType::kEthernet;
 
-    case NetworkConnectionType::kWifi:
-      if (tethering == NetworkTethering::kConfirmed)
+    case ConnectionType::kWifi:
+      if (tethering == ConnectionTethering::kConfirmed)
         return metrics::ConnectionType::kTetheredWifi;
       else
         return metrics::ConnectionType::kWifi;
 
-    case NetworkConnectionType::kWimax:
+    case ConnectionType::kWimax:
       return metrics::ConnectionType::kWimax;
 
-    case NetworkConnectionType::kBluetooth:
+    case ConnectionType::kBluetooth:
       return metrics::ConnectionType::kBluetooth;
 
-    case NetworkConnectionType::kCellular:
+    case ConnectionType::kCellular:
       return metrics::ConnectionType::kCellular;
   }
 
diff --git a/metrics_utils.h b/metrics_utils.h
index 7c3b02d..d9826c1 100644
--- a/metrics_utils.h
+++ b/metrics_utils.h
@@ -17,7 +17,7 @@
 #ifndef UPDATE_ENGINE_METRICS_UTILS_H_
 #define UPDATE_ENGINE_METRICS_UTILS_H_
 
-#include "update_engine/connection_manager.h"
+#include "update_engine/connection_utils.h"
 #include "update_engine/metrics.h"
 
 namespace chromeos_update_engine {
@@ -39,8 +39,8 @@
 metrics::AttemptResult GetAttemptResult(ErrorCode code);
 
 // Calculates the internet connection type given |type| and |tethering|.
-metrics::ConnectionType GetConnectionType(NetworkConnectionType type,
-                                          NetworkTethering tethering);
+metrics::ConnectionType GetConnectionType(ConnectionType type,
+                                          ConnectionTethering tethering);
 
 // This function returns the duration on the wallclock since the last
 // time it was called for the same |state_variable_key| value.
diff --git a/metrics_utils_unittest.cc b/metrics_utils_unittest.cc
index e702c17..edf6bc3 100644
--- a/metrics_utils_unittest.cc
+++ b/metrics_utils_unittest.cc
@@ -30,51 +30,51 @@
 TEST(MetricsUtilsTest, GetConnectionType) {
   // Check that expected combinations map to the right value.
   EXPECT_EQ(metrics::ConnectionType::kUnknown,
-            GetConnectionType(NetworkConnectionType::kUnknown,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kUnknown,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kEthernet,
-            GetConnectionType(NetworkConnectionType::kEthernet,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kEthernet,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kWifi,
-            GetConnectionType(NetworkConnectionType::kWifi,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kWifi,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kWimax,
-            GetConnectionType(NetworkConnectionType::kWimax,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kWimax,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kBluetooth,
-            GetConnectionType(NetworkConnectionType::kBluetooth,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kBluetooth,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kCellular,
-            GetConnectionType(NetworkConnectionType::kCellular,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kCellular,
+                              ConnectionTethering::kUnknown));
   EXPECT_EQ(metrics::ConnectionType::kTetheredEthernet,
-            GetConnectionType(NetworkConnectionType::kEthernet,
-                              NetworkTethering::kConfirmed));
+            GetConnectionType(ConnectionType::kEthernet,
+                              ConnectionTethering::kConfirmed));
   EXPECT_EQ(metrics::ConnectionType::kTetheredWifi,
-            GetConnectionType(NetworkConnectionType::kWifi,
-                              NetworkTethering::kConfirmed));
+            GetConnectionType(ConnectionType::kWifi,
+                              ConnectionTethering::kConfirmed));
 
   // Ensure that we don't report tethered ethernet unless it's confirmed.
   EXPECT_EQ(metrics::ConnectionType::kEthernet,
-            GetConnectionType(NetworkConnectionType::kEthernet,
-                              NetworkTethering::kNotDetected));
+            GetConnectionType(ConnectionType::kEthernet,
+                              ConnectionTethering::kNotDetected));
   EXPECT_EQ(metrics::ConnectionType::kEthernet,
-            GetConnectionType(NetworkConnectionType::kEthernet,
-                              NetworkTethering::kSuspected));
+            GetConnectionType(ConnectionType::kEthernet,
+                              ConnectionTethering::kSuspected));
   EXPECT_EQ(metrics::ConnectionType::kEthernet,
-            GetConnectionType(NetworkConnectionType::kEthernet,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kEthernet,
+                              ConnectionTethering::kUnknown));
 
   // Ditto for tethered wifi.
   EXPECT_EQ(metrics::ConnectionType::kWifi,
-            GetConnectionType(NetworkConnectionType::kWifi,
-                              NetworkTethering::kNotDetected));
+            GetConnectionType(ConnectionType::kWifi,
+                              ConnectionTethering::kNotDetected));
   EXPECT_EQ(metrics::ConnectionType::kWifi,
-            GetConnectionType(NetworkConnectionType::kWifi,
-                              NetworkTethering::kSuspected));
+            GetConnectionType(ConnectionType::kWifi,
+                              ConnectionTethering::kSuspected));
   EXPECT_EQ(metrics::ConnectionType::kWifi,
-            GetConnectionType(NetworkConnectionType::kWifi,
-                              NetworkTethering::kUnknown));
+            GetConnectionType(ConnectionType::kWifi,
+                              ConnectionTethering::kUnknown));
 }
 
 TEST(MetricsUtilsTest, WallclockDurationHelper) {
diff --git a/mock_connection_manager.h b/mock_connection_manager.h
index 109c529..e37460b 100644
--- a/mock_connection_manager.h
+++ b/mock_connection_manager.h
@@ -31,11 +31,11 @@
   MockConnectionManager() = default;
 
   MOCK_METHOD2(GetConnectionProperties,
-               bool(NetworkConnectionType* out_type,
-                    NetworkTethering* out_tethering));
+               bool(ConnectionType* out_type,
+                    ConnectionTethering* out_tethering));
 
-  MOCK_CONST_METHOD2(IsUpdateAllowedOver, bool(NetworkConnectionType type,
-                                               NetworkTethering tethering));
+  MOCK_CONST_METHOD2(IsUpdateAllowedOver,
+                     bool(ConnectionType type, ConnectionTethering tethering));
 };
 
 }  // namespace chromeos_update_engine
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 173d387..7f18cc4 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -40,7 +40,7 @@
 #include "update_engine/common/platform_constants.h"
 #include "update_engine/common/prefs_interface.h"
 #include "update_engine/common/utils.h"
-#include "update_engine/connection_manager.h"
+#include "update_engine/connection_manager_interface.h"
 #include "update_engine/metrics.h"
 #include "update_engine/metrics_utils.h"
 #include "update_engine/omaha_request_params.h"
@@ -1501,8 +1501,8 @@
 }
 
 bool OmahaRequestAction::IsUpdateAllowedOverCurrentConnection() const {
-  NetworkConnectionType type;
-  NetworkTethering tethering;
+  ConnectionType type;
+  ConnectionTethering tethering;
   ConnectionManagerInterface* connection_manager =
       system_state_->connection_manager();
   if (!connection_manager->GetConnectionProperties(&type, &tethering)) {
@@ -1512,7 +1512,7 @@
   }
   bool is_allowed = connection_manager->IsUpdateAllowedOver(type, tethering);
   LOG(INFO) << "We are connected via "
-            << ConnectionManager::StringForConnectionType(type)
+            << connection_utils::StringForConnectionType(type)
             << ", Updates allowed: " << (is_allowed ? "Yes" : "No");
   return is_allowed;
 }
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index d4b166f..82f9ae8 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -467,11 +467,11 @@
 
   EXPECT_CALL(mock_cm, GetConnectionProperties(_, _))
       .WillRepeatedly(
-          DoAll(SetArgumentPointee<0>(NetworkConnectionType::kEthernet),
-                SetArgumentPointee<1>(NetworkTethering::kUnknown),
+          DoAll(SetArgumentPointee<0>(ConnectionType::kEthernet),
+                SetArgumentPointee<1>(ConnectionTethering::kUnknown),
                 Return(true)));
-  EXPECT_CALL(mock_cm, IsUpdateAllowedOver(NetworkConnectionType::kEthernet, _))
-    .WillRepeatedly(Return(false));
+  EXPECT_CALL(mock_cm, IsUpdateAllowedOver(ConnectionType::kEthernet, _))
+      .WillRepeatedly(Return(false));
 
   ASSERT_FALSE(
       TestUpdateCheck(nullptr,  // request_params
diff --git a/payload_state.cc b/payload_state.cc
index af1ad05..1da472f 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -31,6 +31,7 @@
 #include "update_engine/common/hardware_interface.h"
 #include "update_engine/common/prefs.h"
 #include "update_engine/common/utils.h"
+#include "update_engine/connection_manager_interface.h"
 #include "update_engine/metrics_utils.h"
 #include "update_engine/omaha_request_params.h"
 #include "update_engine/payload_consumer/install_plan.h"
@@ -186,8 +187,8 @@
   attempt_num_bytes_downloaded_ = 0;
 
   metrics::ConnectionType type;
-  NetworkConnectionType network_connection_type;
-  NetworkTethering tethering;
+  ConnectionType network_connection_type;
+  ConnectionTethering tethering;
   ConnectionManagerInterface* connection_manager =
       system_state_->connection_manager();
   if (!connection_manager->GetConnectionProperties(&network_connection_type,
diff --git a/update_engine.gyp b/update_engine.gyp
index 7a3be60..880a03a 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -252,6 +252,7 @@
         'boot_control_chromeos.cc',
         'common_service.cc',
         'connection_manager.cc',
+        'connection_utils.cc',
         'daemon.cc',
         'dbus_service.cc',
         'hardware_chromeos.cc',
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index a4aeede..9758d33 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -25,9 +25,13 @@
 #include <base/time/time.h>
 
 #include "update_engine/common/utils.h"
+#include "update_engine/connection_utils.h"
 #include "update_engine/update_manager/shill_provider.h"
 #include "update_engine/update_manager/updater_provider.h"
 
+using chromeos_update_engine::ConnectionTethering;
+using chromeos_update_engine::ConnectionType;
+using chromeos_update_engine::connection_utils::StringForConnectionType;
 using std::set;
 using std::string;
 
@@ -91,29 +95,10 @@
   return chromeos_update_engine::utils::FormatTimeDelta(*val);
 }
 
-static string ConnectionTypeToString(ConnectionType type) {
-  switch (type) {
-    case ConnectionType::kEthernet:
-      return "Ethernet";
-    case ConnectionType::kWifi:
-      return "Wifi";
-    case ConnectionType::kWimax:
-      return "Wimax";
-    case ConnectionType::kBluetooth:
-      return "Bluetooth";
-    case ConnectionType::kCellular:
-      return "Cellular";
-    case ConnectionType::kUnknown:
-      return "Unknown";
-  }
-  NOTREACHED();
-  return "Unknown";
-}
-
 template<>
 string BoxedValue::ValuePrinter<ConnectionType>(const void* value) {
   const ConnectionType* val = reinterpret_cast<const ConnectionType*>(value);
-  return ConnectionTypeToString(*val);
+  return StringForConnectionType(*val);
 }
 
 template<>
@@ -125,7 +110,7 @@
     ConnectionType type = it;
     if (ret.size() > 0)
       ret += ",";
-    ret += ConnectionTypeToString(type);
+    ret += StringForConnectionType(type);
   }
   return ret;
 }
diff --git a/update_manager/boxed_value_unittest.cc b/update_manager/boxed_value_unittest.cc
index 47bfd8f..3d0c72e 100644
--- a/update_manager/boxed_value_unittest.cc
+++ b/update_manager/boxed_value_unittest.cc
@@ -31,6 +31,8 @@
 
 using base::Time;
 using base::TimeDelta;
+using chromeos_update_engine::ConnectionTethering;
+using chromeos_update_engine::ConnectionType;
 using std::list;
 using std::map;
 using std::set;
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 900a845..ec2b9f0 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -33,6 +33,8 @@
 
 using base::Time;
 using base::TimeDelta;
+using chromeos_update_engine::ConnectionTethering;
+using chromeos_update_engine::ConnectionType;
 using chromeos_update_engine::ErrorCode;
 using std::get;
 using std::max;
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index 8a1796f..0c38700 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -32,6 +32,8 @@
 
 using base::Time;
 using base::TimeDelta;
+using chromeos_update_engine::ConnectionTethering;
+using chromeos_update_engine::ConnectionType;
 using chromeos_update_engine::ErrorCode;
 using chromeos_update_engine::FakeClock;
 using std::set;
diff --git a/update_manager/device_policy_provider.h b/update_manager/device_policy_provider.h
index 0eb04c1..3537d13 100644
--- a/update_manager/device_policy_provider.h
+++ b/update_manager/device_policy_provider.h
@@ -52,7 +52,7 @@
   // Variable returning the set of connection types allowed for updates. The
   // identifiers returned are consistent with the ones returned by the
   // ShillProvider.
-  virtual Variable<std::set<ConnectionType>>*
+  virtual Variable<std::set<chromeos_update_engine::ConnectionType>>*
       var_allowed_connection_types_for_update() = 0;
 
   // Variable stating the name of the device owner. For enterprise enrolled
diff --git a/update_manager/fake_device_policy_provider.h b/update_manager/fake_device_policy_provider.h
index 0ab2d3c..9e4f5b7 100644
--- a/update_manager/fake_device_policy_provider.h
+++ b/update_manager/fake_device_policy_provider.h
@@ -54,7 +54,7 @@
     return &var_scatter_factor_;
   }
 
-  FakeVariable<std::set<ConnectionType>>*
+  FakeVariable<std::set<chromeos_update_engine::ConnectionType>>*
       var_allowed_connection_types_for_update() override {
     return &var_allowed_connection_types_for_update_;
   }
@@ -88,7 +88,7 @@
       "target_version_prefix", kVariableModePoll};
   FakeVariable<base::TimeDelta> var_scatter_factor_{
       "scatter_factor", kVariableModePoll};
-  FakeVariable<std::set<ConnectionType>>
+  FakeVariable<std::set<chromeos_update_engine::ConnectionType>>
       var_allowed_connection_types_for_update_{
           "allowed_connection_types_for_update", kVariableModePoll};
   FakeVariable<std::string> var_owner_{"owner", kVariableModePoll};
diff --git a/update_manager/fake_shill_provider.h b/update_manager/fake_shill_provider.h
index b68e858..7f1c8f5 100644
--- a/update_manager/fake_shill_provider.h
+++ b/update_manager/fake_shill_provider.h
@@ -31,11 +31,12 @@
     return &var_is_connected_;
   }
 
-  FakeVariable<ConnectionType>* var_conn_type() override {
+  FakeVariable<chromeos_update_engine::ConnectionType>* var_conn_type()
+      override {
     return &var_conn_type_;
   }
 
-  FakeVariable<ConnectionTethering>*
+  FakeVariable<chromeos_update_engine::ConnectionTethering>*
       var_conn_tethering() override {
     return &var_conn_tethering_;
   }
@@ -46,8 +47,9 @@
 
  private:
   FakeVariable<bool> var_is_connected_{"is_connected", kVariableModePoll};
-  FakeVariable<ConnectionType> var_conn_type_{"conn_type", kVariableModePoll};
-  FakeVariable<ConnectionTethering> var_conn_tethering_{
+  FakeVariable<chromeos_update_engine::ConnectionType> var_conn_type_{
+      "conn_type", kVariableModePoll};
+  FakeVariable<chromeos_update_engine::ConnectionTethering> var_conn_tethering_{
       "conn_tethering", kVariableModePoll};
   FakeVariable<base::Time> var_conn_last_changed_{
       "conn_last_changed", kVariableModePoll};
diff --git a/update_manager/real_device_policy_provider.cc b/update_manager/real_device_policy_provider.cc
index 0e76518..e3e0659 100644
--- a/update_manager/real_device_policy_provider.cc
+++ b/update_manager/real_device_policy_provider.cc
@@ -24,11 +24,12 @@
 #include <policy/device_policy.h>
 
 #include "update_engine/common/utils.h"
+#include "update_engine/connection_utils.h"
 #include "update_engine/update_manager/generic_variables.h"
-#include "update_engine/update_manager/real_shill_provider.h"
 
 using base::TimeDelta;
 using brillo::MessageLoop;
+using chromeos_update_engine::ConnectionType;
 using policy::DevicePolicy;
 using std::set;
 using std::string;
@@ -133,7 +134,7 @@
   allowed_types->clear();
   for (auto& type_str : allowed_types_str) {
     ConnectionType type =
-        RealShillProvider::ParseConnectionType(type_str.c_str());
+        chromeos_update_engine::connection_utils::ParseConnectionType(type_str);
     if (type != ConnectionType::kUnknown) {
       allowed_types->insert(type);
     } else {
diff --git a/update_manager/real_device_policy_provider.h b/update_manager/real_device_policy_provider.h
index 6e798ca..1ccf45b 100644
--- a/update_manager/real_device_policy_provider.h
+++ b/update_manager/real_device_policy_provider.h
@@ -67,7 +67,7 @@
     return &var_scatter_factor_;
   }
 
-  Variable<std::set<ConnectionType>>*
+  Variable<std::set<chromeos_update_engine::ConnectionType>>*
       var_allowed_connection_types_for_update() override {
     return &var_allowed_connection_types_for_update_;
   }
@@ -130,7 +130,7 @@
   // Wrapper for DevicePolicy::GetAllowedConnectionTypesForUpdate() that
   // converts the result to a set of ConnectionType elements instead of strings.
   bool ConvertAllowedConnectionTypesForUpdate(
-      std::set<ConnectionType>* allowed_types) const;
+      std::set<chromeos_update_engine::ConnectionType>* allowed_types) const;
 
   // Used for fetching information about the device policy.
   policy::PolicyProvider* policy_provider_;
@@ -155,7 +155,7 @@
   AsyncCopyVariable<std::string> var_target_version_prefix_{
       "target_version_prefix"};
   AsyncCopyVariable<base::TimeDelta> var_scatter_factor_{"scatter_factor"};
-  AsyncCopyVariable<std::set<ConnectionType>>
+  AsyncCopyVariable<std::set<chromeos_update_engine::ConnectionType>>
       var_allowed_connection_types_for_update_{
           "allowed_connection_types_for_update"};
   AsyncCopyVariable<std::string> var_owner_{"owner"};
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index 09c9095..45aca56 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -34,6 +34,7 @@
 
 using base::TimeDelta;
 using brillo::MessageLoop;
+using chromeos_update_engine::ConnectionType;
 using chromeos_update_engine::dbus_test_utils::MockSignalHandler;
 using std::set;
 using std::string;
diff --git a/update_manager/real_shill_provider.cc b/update_manager/real_shill_provider.cc
index 7938180..2c58a7e 100644
--- a/update_manager/real_shill_provider.cc
+++ b/update_manager/real_shill_provider.cc
@@ -24,39 +24,13 @@
 #include <shill/dbus-constants.h>
 #include <shill/dbus-proxies.h>
 
+using chromeos_update_engine::connection_utils::ParseConnectionType;
 using org::chromium::flimflam::ManagerProxyInterface;
 using org::chromium::flimflam::ServiceProxyInterface;
 using std::string;
 
 namespace chromeos_update_manager {
 
-ConnectionType RealShillProvider::ParseConnectionType(const string& type_str) {
-  if (type_str == shill::kTypeEthernet) {
-    return ConnectionType::kEthernet;
-  } else if (type_str == shill::kTypeWifi) {
-    return ConnectionType::kWifi;
-  } else if (type_str == shill::kTypeWimax) {
-    return ConnectionType::kWimax;
-  } else if (type_str == shill::kTypeBluetooth) {
-    return ConnectionType::kBluetooth;
-  } else if (type_str == shill::kTypeCellular) {
-    return ConnectionType::kCellular;
-  }
-  return ConnectionType::kUnknown;
-}
-
-ConnectionTethering RealShillProvider::ParseConnectionTethering(
-    const string& tethering_str) {
-  if (tethering_str == shill::kTetheringNotDetectedState) {
-    return ConnectionTethering::kNotDetected;
-  } else if (tethering_str == shill::kTetheringSuspectedState) {
-    return ConnectionTethering::kSuspected;
-  } else if (tethering_str == shill::kTetheringConfirmedState) {
-    return ConnectionTethering::kConfirmed;
-  }
-  return ConnectionTethering::kUnknown;
-}
-
 bool RealShillProvider::Init() {
   ManagerProxyInterface* manager_proxy = shill_proxy_->GetManagerProxy();
   if (!manager_proxy)
@@ -157,7 +131,8 @@
     // If the property doesn't contain a string value, the empty string will
     // become kUnknown.
     var_conn_tethering_.SetValue(
-        ParseConnectionTethering(prop_tethering->second.TryGet<string>()));
+        chromeos_update_engine::connection_utils::ParseConnectionTethering(
+            prop_tethering->second.TryGet<string>()));
   }
 
   // Get the connection type.
@@ -175,7 +150,8 @@
         LOG(ERROR) << "No PhysicalTechnology property found for a VPN"
                    << " connection (service: " << default_service_path_.value()
                    << "). Using default kUnknown value.";
-        var_conn_type_.SetValue(ConnectionType::kUnknown);
+        var_conn_type_.SetValue(
+            chromeos_update_engine::ConnectionType::kUnknown);
       } else {
         var_conn_type_.SetValue(
             ParseConnectionType(prop_physical->second.TryGet<string>()));
diff --git a/update_manager/real_shill_provider.h b/update_manager/real_shill_provider.h
index dbd6fc5..815bbfc 100644
--- a/update_manager/real_shill_provider.h
+++ b/update_manager/real_shill_provider.h
@@ -49,11 +49,11 @@
     return &var_is_connected_;
   }
 
-  Variable<ConnectionType>* var_conn_type() override {
+  Variable<chromeos_update_engine::ConnectionType>* var_conn_type() override {
     return &var_conn_type_;
   }
 
-  Variable<ConnectionTethering>* var_conn_tethering() override {
+  Variable<chromeos_update_engine::ConnectionTethering>* var_conn_tethering() override {
     return &var_conn_tethering_;
   }
 
@@ -61,11 +61,6 @@
     return &var_conn_last_changed_;
   }
 
-  // Helper methods for converting shill strings into symbolic values.
-  static ConnectionType ParseConnectionType(const std::string& type_str);
-  static ConnectionTethering ParseConnectionTethering(
-      const std::string& tethering_str);
-
  private:
   // A handler for ManagerProxy.PropertyChanged signal.
   void OnManagerPropertyChanged(const std::string& name,
@@ -92,8 +87,10 @@
 
   // The provider's variables.
   AsyncCopyVariable<bool> var_is_connected_{"is_connected"};
-  AsyncCopyVariable<ConnectionType> var_conn_type_{"conn_type"};
-  AsyncCopyVariable<ConnectionTethering> var_conn_tethering_{"conn_tethering"};
+  AsyncCopyVariable<chromeos_update_engine::ConnectionType> var_conn_type_{
+      "conn_type"};
+  AsyncCopyVariable<chromeos_update_engine::ConnectionTethering>
+      var_conn_tethering_{"conn_tethering"};
   AsyncCopyVariable<base::Time> var_conn_last_changed_{"conn_last_changed"};
 
   DISALLOW_COPY_AND_ASSIGN(RealShillProvider);
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index 2fa0628..59e70f6 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -35,6 +35,8 @@
 
 using base::Time;
 using base::TimeDelta;
+using chromeos_update_engine::ConnectionTethering;
+using chromeos_update_engine::ConnectionType;
 using chromeos_update_engine::FakeClock;
 using org::chromium::flimflam::ManagerProxyMock;
 using org::chromium::flimflam::ServiceProxyMock;
diff --git a/update_manager/shill_provider.h b/update_manager/shill_provider.h
index b40f255..e6f4628 100644
--- a/update_manager/shill_provider.h
+++ b/update_manager/shill_provider.h
@@ -19,27 +19,12 @@
 
 #include <base/time/time.h>
 
+#include "update_engine/connection_utils.h"
 #include "update_engine/update_manager/provider.h"
 #include "update_engine/update_manager/variable.h"
 
 namespace chromeos_update_manager {
 
-enum class ConnectionType {
-  kEthernet,
-  kWifi,
-  kWimax,
-  kBluetooth,
-  kCellular,
-  kUnknown
-};
-
-enum class ConnectionTethering {
-  kNotDetected,
-  kSuspected,
-  kConfirmed,
-  kUnknown,
-};
-
 // Provider for networking related information.
 class ShillProvider : public Provider {
  public:
@@ -50,11 +35,12 @@
 
   // A variable returning the current network connection type. Unknown if not
   // connected.
-  virtual Variable<ConnectionType>* var_conn_type() = 0;
+  virtual Variable<chromeos_update_engine::ConnectionType>* var_conn_type() = 0;
 
   // A variable returning the tethering mode of a network connection. Unknown if
   // not connected.
-  virtual Variable<ConnectionTethering>* var_conn_tethering() = 0;
+  virtual Variable<chromeos_update_engine::ConnectionTethering>*
+      var_conn_tethering() = 0;
 
   // A variable returning the time when network connection last changed.
   // Initialized to current time.