Don't desparse downloaded images

Cuttlefish has not used Android Sparse images in a long time, so it's
unlikely to run into a scenario soon where it is given sparse images by
accident.

However, it will soon begin using Android Sparse images on purpose when
VMM support is added, in which case un-sparsing them would defeat the
purpose.

This also removes the userdata.img desparse (won't contribute anything
with Android Sparse images), which saves ~25 seconds in fetch_cvd
runtime, bringing it down to ~50 seconds on aosp-master.

Test: fetch_cvd && bin/launch_cvd
Bug: 147688004
Change-Id: I7f1791199c69405234a33ecd75ddf402cecbc6dd
diff --git a/host/commands/fetcher/fetch_cvd.cc b/host/commands/fetcher/fetch_cvd.cc
index c4dfc41..308a1bb 100644
--- a/host/commands/fetcher/fetch_cvd.cc
+++ b/host/commands/fetcher/fetch_cvd.cc
@@ -175,21 +175,6 @@
   return files;
 }
 
-bool desparse(const std::string& file) {
-  LOG(INFO) << "Unsparsing " << file;
-  cvd::Command dd_cmd("/bin/dd");
-  dd_cmd.AddParameter("if=", file);
-  dd_cmd.AddParameter("of=", file);
-  dd_cmd.AddParameter("conv=notrunc");
-  dd_cmd.RedirectStdIO(cvd::Subprocess::StdIOChannel::kStdOut,
-                       cvd::Subprocess::StdIOChannel::kStdErr);
-  if (dd_cmd.Start().Wait() != 0) {
-    LOG(ERROR) << "Could not unsparse " << file;
-    return false;
-  }
-  return true;
-}
-
 std::vector<std::string> download_ota_tools(BuildApi* build_api,
                                             const Build& build,
                                             const std::string& target_directory) {
@@ -310,7 +295,6 @@
       if (image_files.empty()) {
         LOG(FATAL) << "Could not download images for " << default_build;
       }
-      desparse(target_dir + "/userdata.img");
       LOG(INFO) << "Adding img-zip files for default build";
       for (auto& file : image_files) {
         LOG(INFO) << file;
diff --git a/host/commands/fetcher/install_zip.cc b/host/commands/fetcher/install_zip.cc
index 4a3ee8d..b3d0e8e 100644
--- a/host/commands/fetcher/install_zip.cc
+++ b/host/commands/fetcher/install_zip.cc
@@ -39,47 +39,16 @@
     return {};
   }
 
-  bool extraction_success = true;
   std::vector<std::string> files =
-      images.size() > 0 ? images : archive.Contents();
-  for (auto it = files.begin(); it != files.end();) {
-    it = (*it == "" || android::base::EndsWith(*it, "/")) ? files.erase(it) : ++it;
-  }
-  for (const auto& file : files) {
-    if (file.find(".img") == std::string::npos) {
-      continue;
-    }
-    std::string extracted_file = target_directory + "/" + file;
-
-    std::string file_input, file_output;
-    cvd::Command file_cmd("/usr/bin/file");
-    file_cmd.AddParameter(extracted_file);
-    auto file_ret = cvd::RunWithManagedStdio(std::move(file_cmd), &file_input,
-                                             &file_output, nullptr);
-    if (file_ret != 0) {
-      LOG(ERROR) << "Unable to run file on " << file << ", returned" << file_ret;
-      extraction_success = false;
-      continue;
-    }
-    if (file_output.find("Android sparse image,") == std::string::npos) {
-      continue;
-    }
-    std::string inflated_file = extracted_file + ".inflated";
-    cvd::Command simg_cmd("/usr/bin/simg2img");
-    simg_cmd.AddParameter(extracted_file);
-    simg_cmd.AddParameter(inflated_file);
-    simg_cmd.RedirectStdIO(cvd::Subprocess::StdIOChannel::kStdOut,
-                           cvd::Subprocess::StdIOChannel::kStdErr);
-    if (simg_cmd.Start().Wait() != 0) {
-      LOG(ERROR) << "Unable to run simg2img on " << file;
-      extraction_success = false;
-      continue;
-    }
-    auto rename_ret = rename(inflated_file.c_str(), extracted_file.c_str());
-    if (rename_ret != 0) {
-      LOG(ERROR) << "Unable to rename deflated version of " << file;
-      extraction_success = false;
+      images.size() > 0 ? std::move(images) : archive.Contents();
+  auto it = files.begin();
+  while (it != files.end()) {
+    if (*it == "" || android::base::EndsWith(*it, "/")) {
+      it = files.erase(it);
+    } else {
+      *it = target_directory + "/" + *it;
+      it++;
     }
   }
-  return extraction_success ? files : std::vector<std::string>{};
+  return files;
 }