Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f8fff03 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

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
parent 7f72b30e
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -1902,16 +1902,6 @@ void FlashAllTool::FlashImage(const Image& image, const std::string& slot, fastb
    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 @@ static void do_update(const char* filename, FlashingPlan* fp) {
    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()) {
+17 −0
Original line number Diff line number Diff line
@@ -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 @@ class FlashAllTool {
    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,