connection_manager_interface.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Copyright (C) 2015 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_INTERFACE_H_
  17. #define UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_
  18. #include <memory>
  19. #include <base/macros.h>
  20. #include "update_engine/connection_utils.h"
  21. namespace chromeos_update_engine {
  22. class SystemState;
  23. // This class exposes a generic interface to the connection manager
  24. // (e.g FlimFlam, Shill, etc.) to consolidate all connection-related
  25. // logic in update_engine.
  26. class ConnectionManagerInterface {
  27. public:
  28. virtual ~ConnectionManagerInterface() = default;
  29. // Populates |out_type| with the type of the network connection
  30. // that we are currently connected and |out_tethering| with the estimate of
  31. // whether that network is being tethered.
  32. virtual bool GetConnectionProperties(ConnectionType* out_type,
  33. ConnectionTethering* out_tethering) = 0;
  34. // Returns true if we're allowed to update the system when we're
  35. // connected to the internet through the given network connection type and the
  36. // given tethering state.
  37. virtual bool IsUpdateAllowedOver(ConnectionType type,
  38. ConnectionTethering tethering) const = 0;
  39. // Returns true if the allowed connection types for update is set in the
  40. // device policy. Otherwise, returns false.
  41. virtual bool IsAllowedConnectionTypesForUpdateSet() const = 0;
  42. protected:
  43. ConnectionManagerInterface() = default;
  44. private:
  45. DISALLOW_COPY_AND_ASSIGN(ConnectionManagerInterface);
  46. };
  47. namespace connection_manager {
  48. // Factory function which creates a ConnectionManager.
  49. std::unique_ptr<ConnectionManagerInterface> CreateConnectionManager(
  50. SystemState* system_state);
  51. } // namespace connection_manager
  52. } // namespace chromeos_update_engine
  53. #endif // UPDATE_ENGINE_CONNECTION_MANAGER_INTERFACE_H_