blob: 52d4f5bd94160874baa6cfade31497895ac530b4 [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(
Yifan Hong6e706b12018-11-09 16:50:51 -080046 const std::string& super_device,
47 uint32_t source_slot,
48 uint32_t target_slot) override;
Yifan Hong537802d2018-08-15 13:15:42 -070049 bool StoreMetadata(const std::string& super_device,
50 android::fs_mgr::MetadataBuilder* builder,
51 uint32_t target_slot) override;
52 bool GetDeviceDir(std::string* path) override;
53
54 private:
55 std::set<std::string> mapped_devices_;
56
57 void CleanupInternal(bool wait);
58
59 DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
60};
61
62} // namespace chromeos_update_engine
63
64#endif // UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_