Android-cuttlefish cvd tool
fake_android_build.h
Go to the documentation of this file.
1//
2// Copyright (C) 2026 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#pragma once
17
18#include <functional>
19#include <map>
20#include <optional>
21#include <set>
22#include <string>
23#include <string_view>
24#include <utility>
25
29
30namespace cuttlefish {
31
33 public:
34 enum class ImageStatus {
35 kExtracted,
36 kUnextracted,
37 kMissing,
38 };
39
41 std::string Name() const override;
42
43 PrettyStruct Pretty() override;
44
46 Result<std::string> ImageFile(std::string_view name,
47 bool extract = true) override;
48 void AddExtractedImage(std::string_view image, std::string_view path);
49 void AddUnextractedImage(std::string_view image);
50 void AddMissingImage(std::string_view image);
51
52 Result<void> SetExtractDir(std::string_view) override;
53
55 void SetAbPartitions(std::set<std::string, std::less<void>>);
56
58 void SetSystemPartitions(std::set<std::string, std::less<void>>);
59
61 void SetVendorPartitions(std::set<std::string, std::less<void>>);
62
64 void SetLogicalPartitions(std::set<std::string, std::less<void>>);
65
67 void SetPhysicalPartitions(std::set<std::string, std::less<void>>);
68
69 private:
70 // An unset value means that calling the getter should return an error.
71 std::optional<std::map<std::string, std::pair<ImageStatus, std::string>,
72 std::less<void>>>
74 std::optional<std::string> extract_dir_;
75 std::optional<std::set<std::string, std::less<void>>> ab_partitions_;
76 std::optional<std::set<std::string, std::less<void>>> system_partitions_;
77 std::optional<std::set<std::string, std::less<void>>> vendor_partitions_;
78 std::optional<std::set<std::string, std::less<void>>> logical_partitions_;
79 std::optional<std::set<std::string, std::less<void>>> physical_partitions_;
80};
81
83
84template <typename Sink>
85void AbslStringify(Sink& sink, FakeAndroidBuild::ImageStatus image_status) {
86 sink.Append(ImageStatusToStringView(image_status));
87}
88
89} // namespace cuttlefish
Definition: android_build.h:48
Definition: fake_android_build.h:32
void AddUnextractedImage(std::string_view image)
Definition: fake_android_build.cc:83
Result< void > SetExtractDir(std::string_view) override
Definition: fake_android_build.cc:97
Result< std::set< std::string, std::less< void > > > Images() override
Definition: fake_android_build.cc:49
std::optional< std::string > extract_dir_
Definition: fake_android_build.h:74
Result< std::set< std::string, std::less< void > > > SystemPartitions() override
Definition: fake_android_build.cc:114
Result< std::set< std::string, std::less< void > > > AbPartitions() override
Definition: fake_android_build.cc:103
std::optional< std::map< std::string, std::pair< ImageStatus, std::string >, std::less< void > > > images_
Definition: fake_android_build.h:73
void SetVendorPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:130
std::optional< std::set< std::string, std::less< void > > > vendor_partitions_
Definition: fake_android_build.h:77
std::optional< std::set< std::string, std::less< void > > > logical_partitions_
Definition: fake_android_build.h:78
void AddExtractedImage(std::string_view image, std::string_view path)
Definition: fake_android_build.cc:75
Result< std::set< std::string, std::less< void > > > VendorPartitions() override
Definition: fake_android_build.cc:125
void AddMissingImage(std::string_view image)
Definition: fake_android_build.cc:90
std::optional< std::set< std::string, std::less< void > > > system_partitions_
Definition: fake_android_build.h:76
Result< std::set< std::string, std::less< void > > > PhysicalPartitions() override
Definition: fake_android_build.cc:147
void SetLogicalPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:141
PrettyStruct Pretty() override
Definition: fake_android_build.cc:38
void SetSystemPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:119
void SetPhysicalPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:152
Result< std::set< std::string, std::less< void > > > LogicalPartitions() override
Definition: fake_android_build.cc:136
std::optional< std::set< std::string, std::less< void > > > ab_partitions_
Definition: fake_android_build.h:75
ImageStatus
Definition: fake_android_build.h:34
std::optional< std::set< std::string, std::less< void > > > physical_partitions_
Definition: fake_android_build.h:79
void SetAbPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:108
std::string Name() const override
Definition: fake_android_build.cc:36
Result< std::string > ImageFile(std::string_view name, bool extract=true) override
Definition: fake_android_build.cc:58
Definition: struct.h:60
char * name
Definition: libf2fs.c:1403
Definition: alloc_driver.h:20
void AbslStringify(Sink &sink, DeviceType device_type)
Definition: device_type.h:42
std::string_view ImageStatusToStringView(FakeAndroidBuild::ImageStatus image_status)
Definition: fake_android_build.cc:157
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
__u32 set
Definition: nl80211.h:1
Definition: image.h:38