fastboot driver: add fetch command in driver

The `fastboot fetch` command is a wrapper around
the fetch protocol. It:

- getvar max-fetch-size
- get the size of the partition
- read the data by chunks, chunk size = max-fetch-size.

The name of the partition is passed directly to the device
(with the usual has-slot magic for flashing etc.) If we support
fetching partitions other than vendor_boot in the future, no change
in the driver is needed.

Bug: 173654501
Test: manual

Change-Id: Ie576eea668234df236b096a372e65c5e91c1e48c
diff --git a/fastboot/fastboot_driver.h b/fastboot/fastboot_driver.h
index 4d7f3c7..f1c094f 100644
--- a/fastboot/fastboot_driver.h
+++ b/fastboot/fastboot_driver.h
@@ -34,6 +34,7 @@
 
 #include <android-base/logging.h>
 #include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
 #include <bootimg.h>
 #include <inttypes.h>
 #include <sparse/sparse.h>
@@ -106,6 +107,9 @@
                    std::vector<std::string>* info = nullptr);
     RetCode SnapshotUpdateCommand(const std::string& command, std::string* response = nullptr,
                                   std::vector<std::string>* info = nullptr);
+    RetCode FetchToFd(const std::string& partition, android::base::borrowed_fd fd,
+                      int64_t offset = -1, int64_t size = -1, std::string* response = nullptr,
+                      std::vector<std::string>* info = nullptr);
 
     /* HIGHER LEVEL COMMANDS -- Composed of the commands above */
     RetCode FlashPartition(const std::string& partition, const std::vector<char>& data);