blob: 870b088f7d76858c0b3f08a1f5da3e3e9ad4a934 [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
Alex Deymo30534502015-07-20 15:06:33 -07008#include <string>
9
Ben Chan05735a12014-09-03 07:48:22 -070010#include <base/macros.h>
Jay Srinivasan43488792012-06-19 00:25:31 -070011
Alex Deymof6ee0162015-07-31 12:35:22 -070012#include "update_engine/connection_manager_interface.h"
Alex Deymo30534502015-07-20 15:06:33 -070013#include "update_engine/dbus_proxies.h"
14#include "update_engine/shill_proxy_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070015
16namespace chromeos_update_engine {
17
Jay Srinivasan43488792012-06-19 00:25:31 -070018class SystemState;
19
Alex Deymof6ee0162015-07-31 12:35:22 -070020// This class implements the concrete class that talks with the connection
21// manager (shill) over DBus.
Alex Deymo30534502015-07-20 15:06:33 -070022// TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
Alex Deymof6ee0162015-07-31 12:35:22 -070023class ConnectionManager : public ConnectionManagerInterface {
Jay Srinivasan43488792012-06-19 00:25:31 -070024 public:
Jay Srinivasan43488792012-06-19 00:25:31 -070025 // Returns the string representation corresponding to the given
26 // connection type.
Alex Deymof6ee0162015-07-31 12:35:22 -070027 static const char* StringForConnectionType(NetworkConnectionType type);
Jay Srinivasan43488792012-06-19 00:25:31 -070028
Alex Deymof6ee0162015-07-31 12:35:22 -070029 // Constructs a new ConnectionManager object initialized with the
30 // given system state.
Alex Deymo30534502015-07-20 15:06:33 -070031 ConnectionManager(ShillProxyInterface* shill_proxy,
32 SystemState* system_state);
Alex Deymof6ee0162015-07-31 12:35:22 -070033 ~ConnectionManager() override = default;
34
Alex Deymo30534502015-07-20 15:06:33 -070035 // ConnectionManagerInterface overrides.
36 bool GetConnectionProperties(NetworkConnectionType* out_type,
37 NetworkTethering* out_tethering) override;
Alex Deymof6ee0162015-07-31 12:35:22 -070038 bool IsUpdateAllowedOver(NetworkConnectionType type,
39 NetworkTethering tethering) const override;
Alex Deymo6ae91202014-03-10 19:21:25 -070040
Jay Srinivasan43488792012-06-19 00:25:31 -070041 private:
Alex Deymo30534502015-07-20 15:06:33 -070042 // Returns (via out_path) the default network path, or empty string if
43 // there's no network up. Returns true on success.
44 bool GetDefaultServicePath(std::string* out_path);
45
46 bool GetServicePathProperties(const std::string& path,
47 NetworkConnectionType* out_type,
48 NetworkTethering* out_tethering);
49
50 // The mockable interface to access the shill DBus proxies.
51 ShillProxyInterface* shill_proxy_;
52
53 // The global context for update_engine.
Jay Srinivasan43488792012-06-19 00:25:31 -070054 SystemState* system_state_;
55
56 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
57};
58
59} // namespace chromeos_update_engine
60
Gilad Arnoldcf175a02014-07-10 16:48:47 -070061#endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_