blob: 864985edef59f6ebdc3e7406940cd89c3db12e27 [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
Alex Deymof6ee0162015-07-31 12:35:22 -070030// This class implements the concrete class that talks with the connection
31// manager (shill) over DBus.
Alex Deymo30534502015-07-20 15:06:33 -070032// TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
Alex Deymof6ee0162015-07-31 12:35:22 -070033class ConnectionManager : public ConnectionManagerInterface {
Jay Srinivasan43488792012-06-19 00:25:31 -070034 public:
Alex Deymof6ee0162015-07-31 12:35:22 -070035 // Constructs a new ConnectionManager object initialized with the
36 // given system state.
Alex Deymo30534502015-07-20 15:06:33 -070037 ConnectionManager(ShillProxyInterface* shill_proxy,
38 SystemState* system_state);
Alex Deymof6ee0162015-07-31 12:35:22 -070039 ~ConnectionManager() override = default;
40
Alex Deymo30534502015-07-20 15:06:33 -070041 // ConnectionManagerInterface overrides.
Sen Jiang255e22b2016-05-20 16:15:29 -070042 bool GetConnectionProperties(ConnectionType* out_type,
43 ConnectionTethering* out_tethering) override;
44 bool IsUpdateAllowedOver(ConnectionType type,
45 ConnectionTethering tethering) const override;
Weidong Guo4b0d6032017-04-17 10:08:38 -070046 bool IsAllowedConnectionTypesForUpdateSet() const override;
Alex Deymo6ae91202014-03-10 19:21:25 -070047
Jay Srinivasan43488792012-06-19 00:25:31 -070048 private:
Alex Deymo30534502015-07-20 15:06:33 -070049 // Returns (via out_path) the default network path, or empty string if
50 // there's no network up. Returns true on success.
Alex Deymo758dd532015-09-09 15:21:22 -070051 bool GetDefaultServicePath(dbus::ObjectPath* out_path);
Alex Deymo30534502015-07-20 15:06:33 -070052
Alex Deymo758dd532015-09-09 15:21:22 -070053 bool GetServicePathProperties(const dbus::ObjectPath& path,
Sen Jiang255e22b2016-05-20 16:15:29 -070054 ConnectionType* out_type,
55 ConnectionTethering* out_tethering);
Alex Deymo30534502015-07-20 15:06:33 -070056
57 // The mockable interface to access the shill DBus proxies.
Sen Jiangf5bebae2016-06-03 15:36:54 -070058 std::unique_ptr<ShillProxyInterface> shill_proxy_;
Alex Deymo30534502015-07-20 15:06:33 -070059
60 // The global context for update_engine.
Jay Srinivasan43488792012-06-19 00:25:31 -070061 SystemState* system_state_;
62
63 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
64};
65
66} // namespace chromeos_update_engine
67
Gilad Arnoldcf175a02014-07-10 16:48:47 -070068#endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_