blob: dc563ef8fea3862dc2db6db8743adace76619749 [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
Weidong Guo421ff332017-04-17 10:08:38 -070020#include <memory>
Alex Deymo30534502015-07-20 15:06:33 -070021#include <string>
22
Ben Chan05735a12014-09-03 07:48:22 -070023#include <base/macros.h>
Alex Deymo758dd532015-09-09 15:21:22 -070024#include <dbus/object_path.h>
Jay Srinivasan43488792012-06-19 00:25:31 -070025
Alex Deymof6ee0162015-07-31 12:35:22 -070026#include "update_engine/connection_manager_interface.h"
Alex Deymo30534502015-07-20 15:06:33 -070027#include "update_engine/shill_proxy_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070028
29namespace chromeos_update_engine {
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:
Alex Deymof6ee0162015-07-31 12:35:22 -070036 // Constructs a new ConnectionManager object initialized with the
37 // given system state.
Alex Deymo30534502015-07-20 15:06:33 -070038 ConnectionManager(ShillProxyInterface* shill_proxy,
39 SystemState* system_state);
Alex Deymof6ee0162015-07-31 12:35:22 -070040 ~ConnectionManager() override = default;
41
Alex Deymo30534502015-07-20 15:06:33 -070042 // ConnectionManagerInterface overrides.
Sen Jiang255e22b2016-05-20 16:15:29 -070043 bool GetConnectionProperties(ConnectionType* out_type,
44 ConnectionTethering* out_tethering) override;
45 bool IsUpdateAllowedOver(ConnectionType type,
46 ConnectionTethering tethering) const override;
Weidong Guo421ff332017-04-17 10:08:38 -070047 bool IsAllowedConnectionTypesForUpdateSet() const override;
Alex Deymo6ae91202014-03-10 19:21:25 -070048
Jay Srinivasan43488792012-06-19 00:25:31 -070049 private:
Alex Deymo30534502015-07-20 15:06:33 -070050 // Returns (via out_path) the default network path, or empty string if
51 // there's no network up. Returns true on success.
Alex Deymo758dd532015-09-09 15:21:22 -070052 bool GetDefaultServicePath(dbus::ObjectPath* out_path);
Alex Deymo30534502015-07-20 15:06:33 -070053
Alex Deymo758dd532015-09-09 15:21:22 -070054 bool GetServicePathProperties(const dbus::ObjectPath& path,
Sen Jiang255e22b2016-05-20 16:15:29 -070055 ConnectionType* out_type,
56 ConnectionTethering* out_tethering);
Alex Deymo30534502015-07-20 15:06:33 -070057
58 // The mockable interface to access the shill DBus proxies.
Sen Jiangf5bebae2016-06-03 15:36:54 -070059 std::unique_ptr<ShillProxyInterface> shill_proxy_;
Alex Deymo30534502015-07-20 15:06:33 -070060
61 // The global context for update_engine.
Jay Srinivasan43488792012-06-19 00:25:31 -070062 SystemState* system_state_;
63
64 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
65};
66
67} // namespace chromeos_update_engine
68
Gilad Arnoldcf175a02014-07-10 16:48:47 -070069#endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_