| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 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 Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 16 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_ | 
|  | 18 | #define UPDATE_ENGINE_CONNECTION_MANAGER_H_ | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 19 |  | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 20 | #include <string> | 
|  | 21 |  | 
| Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 22 | #include <base/macros.h> | 
| Alex Deymo | 758dd53 | 2015-09-09 15:21:22 -0700 | [diff] [blame] | 23 | #include <dbus/object_path.h> | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 24 |  | 
| Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 25 | #include "update_engine/connection_manager_interface.h" | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 26 | #include "update_engine/shill_proxy_interface.h" | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 27 |  | 
|  | 28 | namespace chromeos_update_engine { | 
|  | 29 |  | 
| Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 30 | // This class implements the concrete class that talks with the connection | 
|  | 31 | // manager (shill) over DBus. | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 32 | // TODO(deymo): Remove this class and use ShillProvider from the UpdateManager. | 
| Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 33 | class ConnectionManager : public ConnectionManagerInterface { | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 34 | public: | 
| Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 35 | // Constructs a new ConnectionManager object initialized with the | 
|  | 36 | // given system state. | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 37 | ConnectionManager(ShillProxyInterface* shill_proxy, | 
|  | 38 | SystemState* system_state); | 
| Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 39 | ~ConnectionManager() override = default; | 
|  | 40 |  | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 41 | // ConnectionManagerInterface overrides. | 
| Sen Jiang | 255e22b | 2016-05-20 16:15:29 -0700 | [diff] [blame] | 42 | bool GetConnectionProperties(ConnectionType* out_type, | 
|  | 43 | ConnectionTethering* out_tethering) override; | 
|  | 44 | bool IsUpdateAllowedOver(ConnectionType type, | 
|  | 45 | ConnectionTethering tethering) const override; | 
| Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 46 |  | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 47 | private: | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 48 | // Returns (via out_path) the default network path, or empty string if | 
|  | 49 | // there's no network up. Returns true on success. | 
| Alex Deymo | 758dd53 | 2015-09-09 15:21:22 -0700 | [diff] [blame] | 50 | bool GetDefaultServicePath(dbus::ObjectPath* out_path); | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 51 |  | 
| Alex Deymo | 758dd53 | 2015-09-09 15:21:22 -0700 | [diff] [blame] | 52 | bool GetServicePathProperties(const dbus::ObjectPath& path, | 
| Sen Jiang | 255e22b | 2016-05-20 16:15:29 -0700 | [diff] [blame] | 53 | ConnectionType* out_type, | 
|  | 54 | ConnectionTethering* out_tethering); | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 55 |  | 
|  | 56 | // The mockable interface to access the shill DBus proxies. | 
| Sen Jiang | f5bebae | 2016-06-03 15:36:54 -0700 | [diff] [blame] | 57 | std::unique_ptr<ShillProxyInterface> shill_proxy_; | 
| Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 58 |  | 
|  | 59 | // The global context for update_engine. | 
| Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 60 | SystemState* system_state_; | 
|  | 61 |  | 
|  | 62 | DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 
|  | 63 | }; | 
|  | 64 |  | 
|  | 65 | }  // namespace chromeos_update_engine | 
|  | 66 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 67 | #endif  // UPDATE_ENGINE_CONNECTION_MANAGER_H_ |