2525#include < optional>
2626#include < string>
2727#include < utility>
28+ #include < variant>
2829#include < vector>
2930
3031#include < android-base/strings.h>
5758namespace cuttlefish {
5859namespace {
5960
61+ bool IsSignedBuild (const Build& build) {
62+ if (!std::holds_alternative<DeviceBuild>(build)) {
63+ return false ;
64+ }
65+ const auto & device_build = std::get<DeviceBuild>(build);
66+ return device_build.is_signed ;
67+ }
68+
6069constexpr mode_t kRwxAllMode = S_IRWXU | S_IRWXG | S_IRWXO ;
6170
6271struct Target {
@@ -180,6 +189,7 @@ Result<void> FetchDefaultTarget(FetchBuildContext& context,
180189 bool keep_downloaded_archives,
181190 const DownloadFlags& flags,
182191 bool has_system_build) {
192+ constexpr char kSignedPrefix [] = " signed/signed-" ;
183193 // Some older builds might not have misc_info.txt, so permit errors on
184194 // fetching misc_info.txt
185195 if (!context.Artifact (" misc_info.txt" ).Download ().ok ()) {
@@ -188,7 +198,13 @@ Result<void> FetchDefaultTarget(FetchBuildContext& context,
188198 if (flags.download_img_zip ) {
189199 LOG (INFO ) << " Downloading image zip for " << context;
190200 std::string img_zip_name = context.GetBuildZipName (" img" );
191- FetchArtifact img_zip = context.Artifact (img_zip_name);
201+ std::string img_zip_artifact_name = img_zip_name;
202+ if (IsSignedBuild (context.Build ())) {
203+ img_zip_artifact_name = kSignedPrefix + img_zip_artifact_name;
204+ LOG (INFO ) << " Attempting to fetch SIGNED default image zip: "
205+ << img_zip_artifact_name;
206+ }
207+ FetchArtifact img_zip = context.Artifact (img_zip_artifact_name);
192208 CF_EXPECT (img_zip.Download ());
193209 CF_EXPECT (img_zip.ExtractAll ());
194210 if (!keep_downloaded_archives) {
0 commit comments