blob: f9973a38ed79dab35cae6710a8744e260668c7b4 [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_
6#define UPDATE_ENGINE_CONNECTION_MANAGER_H_
Jay Srinivasan43488792012-06-19 00:25:31 -07007
Ben Chan05735a12014-09-03 07:48:22 -07008#include <base/macros.h>
Jay Srinivasan43488792012-06-19 00:25:31 -07009
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);
Alex Deymoe8948702014-11-11 21:44:45 -080040 virtual ~ConnectionManager() = default;
Jay Srinivasan43488792012-06-19 00:25:31 -070041
42 // Populates |out_type| with the type of the network connection
Alex Deymo6ae91202014-03-10 19:21:25 -070043 // that we are currently connected and |out_tethering| with the estimate of
44 // whether that network is being tethered. The dbus_iface is used to query
45 // the real connection manager (e.g shill).
46 virtual bool GetConnectionProperties(DBusWrapperInterface* dbus_iface,
47 NetworkConnectionType* out_type,
48 NetworkTethering* out_tethering) const;
Jay Srinivasan43488792012-06-19 00:25:31 -070049
50 // Returns true if we're allowed to update the system when we're
Alex Deymo6ae91202014-03-10 19:21:25 -070051 // connected to the internet through the given network connection type and the
52 // given tethering state.
53 virtual bool IsUpdateAllowedOver(NetworkConnectionType type,
54 NetworkTethering tethering) const;
Jay Srinivasan43488792012-06-19 00:25:31 -070055
56 // Returns the string representation corresponding to the given
57 // connection type.
58 virtual const char* StringForConnectionType(NetworkConnectionType type) const;
59
Alex Deymo6ae91202014-03-10 19:21:25 -070060 // Returns the string representation corresponding to the given tethering
61 // state.
62 virtual const char* StringForTethering(NetworkTethering tethering) const;
63
Jay Srinivasan43488792012-06-19 00:25:31 -070064 private:
65 // The global context for update_engine
66 SystemState* system_state_;
67
68 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
69};
70
71} // namespace chromeos_update_engine
72
Gilad Arnoldcf175a02014-07-10 16:48:47 -070073#endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_