blob: cb638b6c5a35b5259517265d4ac7fe6a2cbcd072 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Jay Srinivasan43488792012-06-19 00:25:31 -070016
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_
18#define UPDATE_ENGINE_CONNECTION_MANAGER_H_
Jay Srinivasan43488792012-06-19 00:25:31 -070019
Alex Deymo30534502015-07-20 15:06:33 -070020#include <string>
21
Ben Chan05735a12014-09-03 07:48:22 -070022#include <base/macros.h>
Jay Srinivasan43488792012-06-19 00:25:31 -070023
Alex Deymof6ee0162015-07-31 12:35:22 -070024#include "update_engine/connection_manager_interface.h"
Alex Deymo30534502015-07-20 15:06:33 -070025#include "update_engine/shill_proxy_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070026
27namespace chromeos_update_engine {
28
Jay Srinivasan43488792012-06-19 00:25:31 -070029class SystemState;
30
Alex Deymof6ee0162015-07-31 12:35:22 -070031// This class implements the concrete class that talks with the connection
32// manager (shill) over DBus.
Alex Deymo30534502015-07-20 15:06:33 -070033// TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
Alex Deymof6ee0162015-07-31 12:35:22 -070034class ConnectionManager : public ConnectionManagerInterface {
Jay Srinivasan43488792012-06-19 00:25:31 -070035 public:
Jay Srinivasan43488792012-06-19 00:25:31 -070036 // Returns the string representation corresponding to the given
37 // connection type.
Alex Deymof6ee0162015-07-31 12:35:22 -070038 static const char* StringForConnectionType(NetworkConnectionType type);
Jay Srinivasan43488792012-06-19 00:25:31 -070039
Alex Deymof6ee0162015-07-31 12:35:22 -070040 // Constructs a new ConnectionManager object initialized with the
41 // given system state.
Alex Deymo30534502015-07-20 15:06:33 -070042 ConnectionManager(ShillProxyInterface* shill_proxy,
43 SystemState* system_state);
Alex Deymof6ee0162015-07-31 12:35:22 -070044 ~ConnectionManager() override = default;
45
Alex Deymo30534502015-07-20 15:06:33 -070046 // ConnectionManagerInterface overrides.
47 bool GetConnectionProperties(NetworkConnectionType* out_type,
48 NetworkTethering* out_tethering) override;
Alex Deymof6ee0162015-07-31 12:35:22 -070049 bool IsUpdateAllowedOver(NetworkConnectionType type,
50 NetworkTethering tethering) const override;
Alex Deymo6ae91202014-03-10 19:21:25 -070051
Jay Srinivasan43488792012-06-19 00:25:31 -070052 private:
Alex Deymo30534502015-07-20 15:06:33 -070053 // Returns (via out_path) the default network path, or empty string if
54 // there's no network up. Returns true on success.
55 bool GetDefaultServicePath(std::string* out_path);
56
57 bool GetServicePathProperties(const std::string& path,
58 NetworkConnectionType* out_type,
59 NetworkTethering* out_tethering);
60
61 // The mockable interface to access the shill DBus proxies.
62 ShillProxyInterface* shill_proxy_;
63
64 // The global context for update_engine.
Jay Srinivasan43488792012-06-19 00:25:31 -070065 SystemState* system_state_;
66
67 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
68};
69
70} // namespace chromeos_update_engine
71
Gilad Arnoldcf175a02014-07-10 16:48:47 -070072#endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_