Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_CONNECTION_MANAGER_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_CONNECTION_MANAGER_H_ |
| 7 | |
| 8 | #include <base/basictypes.h> |
| 9 | |
Gilad Arnold | 1b9d6ae | 2014-03-03 13:46:07 -0800 | [diff] [blame] | 10 | #include "update_engine/dbus_wrapper_interface.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 11 | |
| 12 | namespace chromeos_update_engine { |
| 13 | |
| 14 | enum NetworkConnectionType { |
| 15 | kNetEthernet = 0, |
| 16 | kNetWifi, |
| 17 | kNetWimax, |
| 18 | kNetBluetooth, |
| 19 | kNetCellular, |
| 20 | kNetUnknown |
| 21 | }; |
| 22 | |
Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 23 | enum class NetworkTethering { |
| 24 | kNotDetected = 0, |
| 25 | kSuspected, |
| 26 | kConfirmed, |
| 27 | kUnknown |
| 28 | }; |
| 29 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 30 | class SystemState; |
| 31 | |
| 32 | // This class exposes a generic interface to the connection manager |
| 33 | // (e.g FlimFlam, Shill, etc.) to consolidate all connection-related |
| 34 | // logic in update_engine. |
| 35 | class ConnectionManager { |
| 36 | public: |
| 37 | // Constructs a new ConnectionManager object initialized with the |
| 38 | // given system state. |
| 39 | explicit ConnectionManager(SystemState* system_state); |
| 40 | |
| 41 | // Populates |out_type| with the type of the network connection |
Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 42 | // that we are currently connected and |out_tethering| with the estimate of |
| 43 | // whether that network is being tethered. The dbus_iface is used to query |
| 44 | // the real connection manager (e.g shill). |
| 45 | virtual bool GetConnectionProperties(DBusWrapperInterface* dbus_iface, |
| 46 | NetworkConnectionType* out_type, |
| 47 | NetworkTethering* out_tethering) const; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 48 | |
| 49 | // Returns true if we're allowed to update the system when we're |
Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 50 | // connected to the internet through the given network connection type and the |
| 51 | // given tethering state. |
| 52 | virtual bool IsUpdateAllowedOver(NetworkConnectionType type, |
| 53 | NetworkTethering tethering) const; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 54 | |
| 55 | // Returns the string representation corresponding to the given |
| 56 | // connection type. |
| 57 | virtual const char* StringForConnectionType(NetworkConnectionType type) const; |
| 58 | |
Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 59 | // Returns the string representation corresponding to the given tethering |
| 60 | // state. |
| 61 | virtual const char* StringForTethering(NetworkTethering tethering) const; |
| 62 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 63 | private: |
| 64 | // The global context for update_engine |
| 65 | SystemState* system_state_; |
| 66 | |
| 67 | DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 68 | }; |
| 69 | |
| 70 | } // namespace chromeos_update_engine |
| 71 | |
| 72 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CONNECTION_MANAGER_H_ |