blob: b50782bf57680c9016180ddb0b67a11e8be7cfd1 [file] [log] [blame]
Jay Srinivasan43488792012-06-19 00:25:31 -07001// 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 Arnold1b9d6ae2014-03-03 13:46:07 -080010#include "update_engine/dbus_wrapper_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070011
12namespace chromeos_update_engine {
13
14enum NetworkConnectionType {
15 kNetEthernet = 0,
16 kNetWifi,
17 kNetWimax,
18 kNetBluetooth,
19 kNetCellular,
20 kNetUnknown
21};
22
Alex Deymo6ae91202014-03-10 19:21:25 -070023enum class NetworkTethering {
24 kNotDetected = 0,
25 kSuspected,
26 kConfirmed,
27 kUnknown
28};
29
Jay Srinivasan43488792012-06-19 00:25:31 -070030class 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.
35class 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 Deymo6ae91202014-03-10 19:21:25 -070042 // 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 Srinivasan43488792012-06-19 00:25:31 -070048
49 // Returns true if we're allowed to update the system when we're
Alex Deymo6ae91202014-03-10 19:21:25 -070050 // 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 Srinivasan43488792012-06-19 00:25:31 -070054
55 // Returns the string representation corresponding to the given
56 // connection type.
57 virtual const char* StringForConnectionType(NetworkConnectionType type) const;
58
Alex Deymo6ae91202014-03-10 19:21:25 -070059 // Returns the string representation corresponding to the given tethering
60 // state.
61 virtual const char* StringForTethering(NetworkTethering tethering) const;
62
Jay Srinivasan43488792012-06-19 00:25:31 -070063 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_