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 <utility>
24
25#include "absl/strings/string_view.h"
26
30
31namespace cuttlefish {
32
34 public:
35 enum class ImageStatus {
36 kExtracted,
37 kUnextracted,
38 kMissing,
39 };
40
42 std::string Name() const override;
43
44 PrettyStruct Pretty() override;
45
47 Result<std::string> ImageFile(absl::string_view name,
48 bool extract = true) override;
49 void AddExtractedImage(absl::string_view image, absl::string_view path);
50 void AddUnextractedImage(absl::string_view image);
51 void AddMissingImage(absl::string_view image);
52
53 Result<void> SetExtractDir(absl::string_view) override;
54
56 void SetAbPartitions(std::set<std::string, std::less<void>>);
57
59 void SetSystemPartitions(std::set<std::string, std::less<void>>);
60
62 void SetVendorPartitions(std::set<std::string, std::less<void>>);
63
65 void SetLogicalPartitions(std::set<std::string, std::less<void>>);
66
68 void SetPhysicalPartitions(std::set<std::string, std::less<void>>);
69
70 private:
71 // An unset value means that calling the getter should return an error.
72 std::optional<std::map<std::string, std::pair<ImageStatus, std::string>,
73 std::less<void>>>
75 std::optional<std::string> extract_dir_;
76 std::optional<std::set<std::string, std::less<void>>> ab_partitions_;
77 std::optional<std::set<std::string, std::less<void>>> system_partitions_;
78 std::optional<std::set<std::string, std::less<void>>> vendor_partitions_;
79 std::optional<std::set<std::string, std::less<void>>> logical_partitions_;
80 std::optional<std::set<std::string, std::less<void>>> physical_partitions_;
81};
82
84
85template <typename Sink>
86void AbslStringify(Sink& sink, FakeAndroidBuild::ImageStatus image_status) {
87 sink.Append(ImageStatusToStringView(image_status));
88}
89
90} // namespace cuttlefish
Definition: android_build.h:49
Definition: fake_android_build.h:33
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:75
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:74
void SetVendorPartitions(std::set< std::string, std::less< void > >)
Definition: fake_android_build.cc:130
Result< std::string > ImageFile(absl::string_view name, bool extract=true) override
Definition: fake_android_build.cc:58
std::optional< std::set< std::string, std::less< void > > > vendor_partitions_
Definition: fake_android_build.h:78
std::optional< std::set< std::string, std::less< void > > > logical_partitions_
Definition: fake_android_build.h:79
Result< std::set< std::string, std::less< void > > > VendorPartitions() override
Definition: fake_android_build.cc:125
std::optional< std::set< std::string, std::less< void > > > system_partitions_
Definition: fake_android_build.h:77
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
void AddUnextractedImage(absl::string_view image)
Definition: fake_android_build.cc:83
Result< void > SetExtractDir(absl::string_view) override
Definition: fake_android_build.cc:97
std::optional< std::set< std::string, std::less< void > > > ab_partitions_
Definition: fake_android_build.h:76
ImageStatus
Definition: fake_android_build.h:35
void AddMissingImage(absl::string_view image)
Definition: fake_android_build.cc:90
std::optional< std::set< std::string, std::less< void > > > physical_partitions_
Definition: fake_android_build.h:80
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
void AddExtractedImage(absl::string_view image, absl::string_view path)
Definition: fake_android_build.cc:75
Definition: struct.h:60
Definition: alloc_driver.h:21
void AbslStringify(Sink &sink, DeviceType device_type)
Definition: device_type.h:44
absl::string_view ImageStatusToStringView(FakeAndroidBuild::ImageStatus image_status)
Definition: fake_android_build.cc:157
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
__u32 set
Definition: nl80211.h:1
Definition: image.h:38