Home | History | Annotate | Download | only in update_engine
      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 //
     16 
     17 #ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_
     18 #define UPDATE_ENGINE_CONNECTION_MANAGER_H_
     19 
     20 #include <string>
     21 
     22 #include <base/macros.h>
     23 #include <dbus/object_path.h>
     24 
     25 #include "update_engine/connection_manager_interface.h"
     26 #include "update_engine/shill_proxy_interface.h"
     27 
     28 namespace chromeos_update_engine {
     29 
     30 class SystemState;
     31 
     32 // This class implements the concrete class that talks with the connection
     33 // manager (shill) over DBus.
     34 // TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
     35 class ConnectionManager : public ConnectionManagerInterface {
     36  public:
     37   // Returns the string representation corresponding to the given
     38   // connection type.
     39   static const char* StringForConnectionType(NetworkConnectionType type);
     40 
     41   // Constructs a new ConnectionManager object initialized with the
     42   // given system state.
     43   ConnectionManager(ShillProxyInterface* shill_proxy,
     44                     SystemState* system_state);
     45   ~ConnectionManager() override = default;
     46 
     47   // ConnectionManagerInterface overrides.
     48   bool GetConnectionProperties(NetworkConnectionType* out_type,
     49                                NetworkTethering* out_tethering) override;
     50   bool IsUpdateAllowedOver(NetworkConnectionType type,
     51                            NetworkTethering tethering) const override;
     52 
     53  private:
     54   // Returns (via out_path) the default network path, or empty string if
     55   // there's no network up. Returns true on success.
     56   bool GetDefaultServicePath(dbus::ObjectPath* out_path);
     57 
     58   bool GetServicePathProperties(const dbus::ObjectPath& path,
     59                                 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.
     66   SystemState* system_state_;
     67 
     68   DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
     69 };
     70 
     71 }  // namespace chromeos_update_engine
     72 
     73 #endif  // UPDATE_ENGINE_CONNECTION_MANAGER_H_
     74