Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 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 | |
| 17 | #ifndef UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_ |
| 18 | #define UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_ |
| 19 | |
| 20 | #include "update_engine/dynamic_partition_control_interface.h" |
| 21 | |
| 22 | #include <memory> |
| 23 | #include <set> |
| 24 | #include <string> |
| 25 | |
| 26 | namespace chromeos_update_engine { |
| 27 | |
| 28 | class DynamicPartitionControlAndroid : public DynamicPartitionControlInterface { |
| 29 | public: |
| 30 | DynamicPartitionControlAndroid() = default; |
| 31 | ~DynamicPartitionControlAndroid(); |
| 32 | bool IsDynamicPartitionsEnabled() override; |
Yifan Hong | 6e38b35 | 2018-11-19 14:12:37 -0800 | [diff] [blame] | 33 | bool IsDynamicPartitionsRetrofit() override; |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 34 | bool MapPartitionOnDeviceMapper(const std::string& super_device, |
| 35 | const std::string& target_partition_name, |
| 36 | uint32_t slot, |
Yifan Hong | af65ef1 | 2018-10-29 11:09:06 -0700 | [diff] [blame] | 37 | bool force_writable, |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 38 | std::string* path) override; |
David Anderson | 4c891c9 | 2019-06-21 17:45:23 -0700 | [diff] [blame] | 39 | bool UnmapPartitionOnDeviceMapper( |
| 40 | const std::string& target_partition_name) override; |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 41 | void Cleanup() override; |
| 42 | bool DeviceExists(const std::string& path) override; |
| 43 | android::dm::DmDeviceState GetState(const std::string& name) override; |
| 44 | bool GetDmDevicePathByName(const std::string& name, |
| 45 | std::string* path) override; |
| 46 | std::unique_ptr<android::fs_mgr::MetadataBuilder> LoadMetadataBuilder( |
Yifan Hong | 6e706b1 | 2018-11-09 16:50:51 -0800 | [diff] [blame] | 47 | const std::string& super_device, |
| 48 | uint32_t source_slot, |
| 49 | uint32_t target_slot) override; |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 50 | bool StoreMetadata(const std::string& super_device, |
| 51 | android::fs_mgr::MetadataBuilder* builder, |
| 52 | uint32_t target_slot) override; |
| 53 | bool GetDeviceDir(std::string* path) override; |
| 54 | |
| 55 | private: |
| 56 | std::set<std::string> mapped_devices_; |
| 57 | |
| 58 | void CleanupInternal(bool wait); |
Yifan Hong | 8546a71 | 2019-03-28 14:42:53 -0700 | [diff] [blame] | 59 | bool MapPartitionInternal(const std::string& super_device, |
| 60 | const std::string& target_partition_name, |
| 61 | uint32_t slot, |
| 62 | bool force_writable, |
| 63 | std::string* path); |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 64 | |
| 65 | DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid); |
| 66 | }; |
| 67 | |
| 68 | } // namespace chromeos_update_engine |
| 69 | |
| 70 | #endif // UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_ |