connection_manager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_
  17. #define UPDATE_ENGINE_CONNECTION_MANAGER_H_
  18. #include <memory>
  19. #include <string>
  20. #include <base/macros.h>
  21. #include <dbus/object_path.h>
  22. #include "update_engine/connection_manager_interface.h"
  23. #include "update_engine/shill_proxy_interface.h"
  24. namespace chromeos_update_engine {
  25. // This class implements the concrete class that talks with the connection
  26. // manager (shill) over DBus.
  27. // TODO(deymo): Remove this class and use ShillProvider from the UpdateManager.
  28. class ConnectionManager : public ConnectionManagerInterface {
  29. public:
  30. // Constructs a new ConnectionManager object initialized with the
  31. // given system state.
  32. ConnectionManager(ShillProxyInterface* shill_proxy,
  33. SystemState* system_state);
  34. ~ConnectionManager() override = default;
  35. // ConnectionManagerInterface overrides.
  36. bool GetConnectionProperties(ConnectionType* out_type,
  37. ConnectionTethering* out_tethering) override;
  38. bool IsUpdateAllowedOver(ConnectionType type,
  39. ConnectionTethering tethering) const override;
  40. bool IsAllowedConnectionTypesForUpdateSet() const override;
  41. private:
  42. // Returns (via out_path) the default network path, or "/" if there's no
  43. // network up. Returns true on success.
  44. bool GetDefaultServicePath(dbus::ObjectPath* out_path);
  45. bool GetServicePathProperties(const dbus::ObjectPath& path,
  46. ConnectionType* out_type,
  47. ConnectionTethering* out_tethering);
  48. // The mockable interface to access the shill DBus proxies.
  49. std::unique_ptr<ShillProxyInterface> shill_proxy_;
  50. // The global context for update_engine.
  51. SystemState* system_state_;
  52. DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
  53. };
  54. } // namespace chromeos_update_engine
  55. #endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_