blob: bb54ff7af38b0eb3bfc80dd269e769bd1119dd5f [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
Amin Hassaniec7bc112020-10-29 16:47:58 -070017#ifndef UPDATE_ENGINE_CROS_CONNECTION_MANAGER_H_
18#define UPDATE_ENGINE_CROS_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
Amin Hassaniec7bc112020-10-29 16:47:58 -070026#include "update_engine/cros/connection_manager_interface.h"
27#include "update_engine/cros/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.
Amin Hassani538bd592020-11-04 20:46:08 -080038 explicit ConnectionManager(ShillProxyInterface* shill_proxy);
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 Guo421ff332017-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:
Colin Howesc9e98d62018-09-18 10:35:20 -070049 // Returns (via out_path) the default network path, or "/" if there's no
50 // 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
Jay Srinivasan43488792012-06-19 00:25:31 -070060 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
61};
62
63} // namespace chromeos_update_engine
64
Amin Hassaniec7bc112020-10-29 16:47:58 -070065#endif // UPDATE_ENGINE_CROS_CONNECTION_MANAGER_H_