dynamic_partition_control_android.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // Copyright (C) 2018 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_DYNAMIC_PARTITION_CONTROL_ANDROID_H_
  17. #define UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_
  18. #include "update_engine/dynamic_partition_control_interface.h"
  19. #include <memory>
  20. #include <set>
  21. #include <string>
  22. namespace chromeos_update_engine {
  23. class DynamicPartitionControlAndroid : public DynamicPartitionControlInterface {
  24. public:
  25. DynamicPartitionControlAndroid() = default;
  26. ~DynamicPartitionControlAndroid();
  27. bool IsDynamicPartitionsEnabled() override;
  28. bool IsDynamicPartitionsRetrofit() override;
  29. bool MapPartitionOnDeviceMapper(const std::string& super_device,
  30. const std::string& target_partition_name,
  31. uint32_t slot,
  32. bool force_writable,
  33. std::string* path) override;
  34. bool UnmapPartitionOnDeviceMapper(const std::string& target_partition_name,
  35. bool wait) override;
  36. void Cleanup() override;
  37. bool DeviceExists(const std::string& path) override;
  38. android::dm::DmDeviceState GetState(const std::string& name) override;
  39. bool GetDmDevicePathByName(const std::string& name,
  40. std::string* path) override;
  41. std::unique_ptr<android::fs_mgr::MetadataBuilder> LoadMetadataBuilder(
  42. const std::string& super_device,
  43. uint32_t source_slot,
  44. uint32_t target_slot) override;
  45. bool StoreMetadata(const std::string& super_device,
  46. android::fs_mgr::MetadataBuilder* builder,
  47. uint32_t target_slot) override;
  48. bool GetDeviceDir(std::string* path) override;
  49. private:
  50. std::set<std::string> mapped_devices_;
  51. void CleanupInternal(bool wait);
  52. bool MapPartitionInternal(const std::string& super_device,
  53. const std::string& target_partition_name,
  54. uint32_t slot,
  55. bool force_writable,
  56. std::string* path);
  57. DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
  58. };
  59. } // namespace chromeos_update_engine
  60. #endif // UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_