blob: 91c9f87769be9c060522ece3d1ed7f3a52f1e044 [file] [log] [blame]
Yifan Hong537802d2018-08-15 13:15:42 -07001//
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
26namespace chromeos_update_engine {
27
28class DynamicPartitionControlAndroid : public DynamicPartitionControlInterface {
29 public:
30 DynamicPartitionControlAndroid() = default;
31 ~DynamicPartitionControlAndroid();
32 bool IsDynamicPartitionsEnabled() override;
33 bool MapPartitionOnDeviceMapper(const std::string& super_device,
34 const std::string& target_partition_name,
35 uint32_t slot,
Yifan Hongaf65ef12018-10-29 11:09:06 -070036 bool force_writable,
Yifan Hong537802d2018-08-15 13:15:42 -070037 std::string* path) override;
38 bool UnmapPartitionOnDeviceMapper(const std::string& target_partition_name,
39 bool wait) override;
40 void Cleanup() override;
41 bool DeviceExists(const std::string& path) override;
42 android::dm::DmDeviceState GetState(const std::string& name) override;
43 bool GetDmDevicePathByName(const std::string& name,
44 std::string* path) override;
45 std::unique_ptr<android::fs_mgr::MetadataBuilder> LoadMetadataBuilder(
46 const std::string& super_device, uint32_t source_slot) override;
47 bool StoreMetadata(const std::string& super_device,
48 android::fs_mgr::MetadataBuilder* builder,
49 uint32_t target_slot) override;
50 bool GetDeviceDir(std::string* path) override;
51
52 private:
53 std::set<std::string> mapped_devices_;
54
55 void CleanupInternal(bool wait);
56
57 DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
58};
59
60} // namespace chromeos_update_engine
61
62#endif // UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_