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 | |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 10 | namespace chromeos_update_engine { |
| 11 | |
| 12 | enum class NetworkConnectionType { |
| 13 | kEthernet, |
| 14 | kWifi, |
| 15 | kWimax, |
| 16 | kBluetooth, |
| 17 | kCellular, |
| 18 | kUnknown |
| 19 | }; |
| 20 | |
| 21 | enum class NetworkTethering { |
| 22 | kNotDetected, |
| 23 | kSuspected, |
| 24 | kConfirmed, |
| 25 | kUnknown |
| 26 | }; |
| 27 | |
| 28 | // This class exposes a generic interface to the connection manager |
| 29 | // (e.g FlimFlam, Shill, etc.) to consolidate all connection-related |
| 30 | // logic in update_engine. |
| 31 | class ConnectionManagerInterface { |
| 32 | public: |
| 33 | virtual ~ConnectionManagerInterface() = default; |
| 34 | |
| 35 | // Populates |out_type| with the type of the network connection |
| 36 | // that we are currently connected and |out_tethering| with the estimate of |
| 37 | // whether that network is being tethered. |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame^] | 38 | virtual bool GetConnectionProperties(NetworkConnectionType* out_type, |
| 39 | NetworkTethering* out_tethering) = 0; |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 40 | |
| 41 | // Returns true if we're allowed to update the system when we're |
| 42 | // connected to the internet through the given network connection type and the |
| 43 | // given tethering state. |
| 44 | virtual bool IsUpdateAllowedOver(NetworkConnectionType type, |
| 45 | NetworkTethering tethering) const = 0; |
| 46 | |
| 47 | protected: |
| 48 | ConnectionManagerInterface() = default; |
| 49 | |
| 50 | private: |
| 51 | DISALLOW_COPY_AND_ASSIGN(ConnectionManagerInterface); |
| 52 | }; |
| 53 | |
| 54 | } // namespace chromeos_update_engine |
| 55 | |
| 56 | #endif // UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_ |