Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_ |
| 6 | #define UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_ |
| 7 | |
| 8 | #include <base/macros.h> |
| 9 | |
| 10 | #include "update_engine/dbus_wrapper_interface.h" |
| 11 | |
| 12 | namespace chromeos_update_engine { |
| 13 | |
| 14 | enum class NetworkConnectionType { |
| 15 | kEthernet, |
| 16 | kWifi, |
| 17 | kWimax, |
| 18 | kBluetooth, |
| 19 | kCellular, |
| 20 | kUnknown |
| 21 | }; |
| 22 | |
| 23 | enum class NetworkTethering { |
| 24 | kNotDetected, |
| 25 | kSuspected, |
| 26 | kConfirmed, |
| 27 | kUnknown |
| 28 | }; |
| 29 | |
| 30 | // This class exposes a generic interface to the connection manager |
| 31 | // (e.g FlimFlam, Shill, etc.) to consolidate all connection-related |
| 32 | // logic in update_engine. |
| 33 | class ConnectionManagerInterface { |
| 34 | public: |
| 35 | virtual ~ConnectionManagerInterface() = default; |
| 36 | |
| 37 | // Populates |out_type| with the type of the network connection |
| 38 | // that we are currently connected and |out_tethering| with the estimate of |
| 39 | // whether that network is being tethered. |
| 40 | virtual bool GetConnectionProperties( |
| 41 | DBusWrapperInterface* dbus_iface, |
| 42 | NetworkConnectionType* out_type, |
| 43 | NetworkTethering* out_tethering) const = 0; |
| 44 | |
| 45 | // Returns true if we're allowed to update the system when we're |
| 46 | // connected to the internet through the given network connection type and the |
| 47 | // given tethering state. |
| 48 | virtual bool IsUpdateAllowedOver(NetworkConnectionType type, |
| 49 | NetworkTethering tethering) const = 0; |
| 50 | |
| 51 | protected: |
| 52 | ConnectionManagerInterface() = default; |
| 53 | |
| 54 | private: |
| 55 | DISALLOW_COPY_AND_ASSIGN(ConnectionManagerInterface); |
| 56 | }; |
| 57 | |
| 58 | } // namespace chromeos_update_engine |
| 59 | |
| 60 | #endif // UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_ |