Moving source class declaration
Moving zipImageSource and localImageSource to header file to be used for
testing purposes
Test: m fastboot
Bug: 194686221
Change-Id: I689e73eb0102d3b2cdd0c4fc232b2b60b9022c47
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 287285b..4678655 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1902,16 +1902,6 @@
do_for_partitions(image.part_name, slot, flash, false);
}
-class ZipImageSource final : public ImageSource {
- public:
- explicit ZipImageSource(ZipArchiveHandle zip) : zip_(zip) {}
- bool ReadFile(const std::string& name, std::vector<char>* out) const override;
- unique_fd OpenFile(const std::string& name) const override;
-
- private:
- ZipArchiveHandle zip_;
-};
-
bool ZipImageSource::ReadFile(const std::string& name, std::vector<char>* out) const {
return UnzipToMemory(zip_, name, out);
}
@@ -1935,12 +1925,6 @@
CloseArchive(zip);
}
-class LocalImageSource final : public ImageSource {
- public:
- bool ReadFile(const std::string& name, std::vector<char>* out) const override;
- unique_fd OpenFile(const std::string& name) const override;
-};
-
bool LocalImageSource::ReadFile(const std::string& name, std::vector<char>* out) const {
auto path = find_item_given_name(name);
if (path.empty()) {
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index abdf636..4b48d4a 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -40,6 +40,7 @@
#include "result.h"
#include "socket.h"
#include "util.h"
+#include "ziparchive/zip_archive.h"
class FastBootTool {
public:
@@ -122,6 +123,22 @@
FlashingPlan* fp_;
};
+class ZipImageSource final : public ImageSource {
+ public:
+ explicit ZipImageSource(ZipArchiveHandle zip) : zip_(zip) {}
+ bool ReadFile(const std::string& name, std::vector<char>* out) const override;
+ unique_fd OpenFile(const std::string& name) const override;
+
+ private:
+ ZipArchiveHandle zip_;
+};
+
+class LocalImageSource final : public ImageSource {
+ public:
+ bool ReadFile(const std::string& name, std::vector<char>* out) const override;
+ unique_fd OpenFile(const std::string& name) const override;
+};
+
bool should_flash_in_userspace(const std::string& partition_name);
bool is_userspace_fastboot();
void do_flash(const char* pname, const char* fname, const bool apply_vbmeta,