blob: 2057f3b143ab6e424345ed1cf2cc3b354a916a7e [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>
Alex Deymo758dd532015-09-09 15:21:22 -070023#include <dbus/object_path.h>
Jay Srinivasan43488792012-06-19 00:25:31 -070024
Alex Deymof6ee0162015-07-31 12:35:22 -070025#include "update_engine/connection_manager_interface.h"
Alex Deymo30534502015-07-20 15:06:33 -070026#include "update_engine/shill_proxy_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070027
28namespace chromeos_update_engine {
29
Jay Srinivasan43488792012-06-19 00:25:31 -070030class SystemState;
31
Alex Deymof6ee0162015-07-31 12:35:22 -070032// This class implements the concrete class that talks with the connection
33// manager (shill) over DBus.
Alex Deymo30534502015-07-20 15:06:33 -070034// TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
Alex Deymof6ee0162015-07-31 12:35:22 -070035class ConnectionManager : public ConnectionManagerInterface {
Jay Srinivasan43488792012-06-19 00:25:31 -070036 public:
Jay Srinivasan43488792012-06-19 00:25:31 -070037 // Returns the string representation corresponding to the given
38 // connection type.
Alex Deymof6ee0162015-07-31 12:35:22 -070039 static const char* StringForConnectionType(NetworkConnectionType type);
Jay Srinivasan43488792012-06-19 00:25:31 -070040
Alex Deymof6ee0162015-07-31 12:35:22 -070041 // Constructs a new ConnectionManager object initialized with the
42 // given system state.
Alex Deymo30534502015-07-20 15:06:33 -070043 ConnectionManager(ShillProxyInterface* shill_proxy,
44 SystemState* system_state);
Alex Deymof6ee0162015-07-31 12:35:22 -070045 ~ConnectionManager() override = default;
46
Alex Deymo30534502015-07-20 15:06:33 -070047 // ConnectionManagerInterface overrides.
48 bool GetConnectionProperties(NetworkConnectionType* out_type,
49 NetworkTethering* out_tethering) override;
Alex Deymof6ee0162015-07-31 12:35:22 -070050 bool IsUpdateAllowedOver(NetworkConnectionType type,
51 NetworkTethering tethering) const override;
Alex Deymo6ae91202014-03-10 19:21:25 -070052
Jay Srinivasan43488792012-06-19 00:25:31 -070053 private:
Alex Deymo30534502015-07-20 15:06:33 -070054 // Returns (via out_path) the default network path, or empty string if
55 // there's no network up. Returns true on success.
Alex Deymo758dd532015-09-09 15:21:22 -070056 bool GetDefaultServicePath(dbus::ObjectPath* out_path);
Alex Deymo30534502015-07-20 15:06:33 -070057
Alex Deymo758dd532015-09-09 15:21:22 -070058 bool GetServicePathProperties(const dbus::ObjectPath& path,
Alex Deymo30534502015-07-20 15:06:33 -070059 NetworkConnectionType* out_type,
60 NetworkTethering* out_tethering);
61
62 // The mockable interface to access the shill DBus proxies.
63 ShillProxyInterface* shill_proxy_;
64
65 // The global context for update_engine.
Jay Srinivasan43488792012-06-19 00:25:31 -070066 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_