blob: 0ccab4ef5852e04520e741bdfccd27fabf9e3fca [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;
Yifan Hong6e38b352018-11-19 14:12:37 -080033 bool IsDynamicPartitionsRetrofit() override;
Yifan Hong537802d2018-08-15 13:15:42 -070034 bool MapPartitionOnDeviceMapper(const std::string& super_device,
35 const std::string& target_partition_name,
36 uint32_t slot,
Yifan Hongaf65ef12018-10-29 11:09:06 -070037 bool force_writable,
Yifan Hong537802d2018-08-15 13:15:42 -070038 std::string* path) override;
39 bool UnmapPartitionOnDeviceMapper(const std::string& target_partition_name,
40 bool wait) override;
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 Hong6e706b12018-11-09 16:50:51 -080047 const std::string& super_device,
48 uint32_t source_slot,
49 uint32_t target_slot) override;
Yifan Hong537802d2018-08-15 13:15:42 -070050 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);
59
60 DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
61};
62
63} // namespace chromeos_update_engine
64
65#endif // UPDATE_ENGINE_DYNAMIC_PARTITION_CONTROL_ANDROID_H_