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

Commit c596830f authored by Daniel Zheng's avatar Daniel Zheng Committed by Gerrit Code Review
Browse files

Merge "Changing name of flash super layout"

parents 732d410d 3e04857a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1747,7 +1747,7 @@ std::vector<std::unique_ptr<Task>> ParseFastbootInfo(const FlashingPlan* fp,
        }
        tasks.emplace_back(std::move(task));
    }
    if (auto flash_super_task = FlashSuperLayoutTask::InitializeFromTasks(fp, tasks)) {
    if (auto flash_super_task = OptimizedFlashSuperTask::InitializeFromTasks(fp, tasks)) {
        auto it = tasks.begin();
        for (size_t i = 0; i < tasks.size(); i++) {
            if (auto flash_task = tasks[i]->AsFlashTask()) {
@@ -1849,7 +1849,7 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() {
    std::vector<std::unique_ptr<Task>> tasks;
    AddFlashTasks(boot_images_, tasks);

    if (auto flash_super_task = FlashSuperLayoutTask::Initialize(fp_, os_images_)) {
    if (auto flash_super_task = OptimizedFlashSuperTask::Initialize(fp_, os_images_)) {
        tasks.emplace_back(std::move(flash_super_task));
    } else {
        // Sync the super partition. This will reboot to userspace fastboot if needed.
@@ -2205,8 +2205,9 @@ int FastBootTool::Main(int argc, char* argv[]) {
                                      {0, 0, 0, 0}};

    serial = getenv("FASTBOOT_DEVICE");
    if (!serial)
    if (!serial) {
        serial = getenv("ANDROID_SERIAL");
    }

    int c;
    while ((c = getopt_long(argc, argv, "a::hls:S:vw", longopts, &longindex)) != -1) {
+12 −12
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ std::string RebootTask::ToString() {
    return "reboot " + reboot_target_;
}

FlashSuperLayoutTask::FlashSuperLayoutTask(const std::string& super_name,
OptimizedFlashSuperTask::OptimizedFlashSuperTask(const std::string& super_name,
                                                 std::unique_ptr<SuperFlashHelper> helper,
                                                 SparsePtr sparse_layout, uint64_t super_size,
                                                 const FlashingPlan* fp)
@@ -106,7 +106,7 @@ FlashSuperLayoutTask::FlashSuperLayoutTask(const std::string& super_name,
      super_size_(super_size),
      fp_(fp) {}

void FlashSuperLayoutTask::Run() {
void OptimizedFlashSuperTask::Run() {
    // Use the reported super partition size as the upper limit, rather than
    // sparse_file_len, which (1) can fail and (2) is kind of expensive, since
    // it will map in all of the embedded fds.
@@ -120,11 +120,11 @@ void FlashSuperLayoutTask::Run() {
    // Send the data to the device.
    flash_partition_files(super_name_, files);
}
std::string FlashSuperLayoutTask::ToString() {
std::string OptimizedFlashSuperTask::ToString() {
    return "optimized-flash-super";
}

std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
std::unique_ptr<OptimizedFlashSuperTask> OptimizedFlashSuperTask::Initialize(
        const FlashingPlan* fp, std::vector<ImageEntry>& os_images) {
    if (!fp->should_optimize_flash_super) {
        LOG(INFO) << "super optimization is disabled";
@@ -188,11 +188,11 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
    };
    os_images.erase(std::remove_if(os_images.begin(), os_images.end(), remove_if_callback),
                    os_images.end());
    return std::make_unique<FlashSuperLayoutTask>(super_name, std::move(helper), std::move(s),
    return std::make_unique<OptimizedFlashSuperTask>(super_name, std::move(helper), std::move(s),
                                                     partition_size, fp);
}

std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::InitializeFromTasks(
std::unique_ptr<OptimizedFlashSuperTask> OptimizedFlashSuperTask::InitializeFromTasks(
        const FlashingPlan* fp, std::vector<std::unique_ptr<Task>>& tasks) {
    if (!fp->should_optimize_flash_super) {
        LOG(INFO) << "super optimization is disabled";
@@ -261,7 +261,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::InitializeFromTasks(
    };
    tasks.erase(std::remove_if(tasks.begin(), tasks.end(), remove_if_callback), tasks.end());

    return std::make_unique<FlashSuperLayoutTask>(super_name, std::move(helper), std::move(s),
    return std::make_unique<OptimizedFlashSuperTask>(super_name, std::move(helper), std::move(s),
                                                     partition_size, fp);
}

+6 −6
Original line number Diff line number Diff line
@@ -79,13 +79,13 @@ class RebootTask : public Task {
    const FlashingPlan* fp_;
};

class FlashSuperLayoutTask : public Task {
class OptimizedFlashSuperTask : public Task {
  public:
    FlashSuperLayoutTask(const std::string& super_name, std::unique_ptr<SuperFlashHelper> helper,
    OptimizedFlashSuperTask(const std::string& super_name, std::unique_ptr<SuperFlashHelper> helper,
                            SparsePtr sparse_layout, uint64_t super_size, const FlashingPlan* fp);
    static std::unique_ptr<FlashSuperLayoutTask> Initialize(const FlashingPlan* fp,
    static std::unique_ptr<OptimizedFlashSuperTask> Initialize(const FlashingPlan* fp,
                                                               std::vector<ImageEntry>& os_images);
    static std::unique_ptr<FlashSuperLayoutTask> InitializeFromTasks(
    static std::unique_ptr<OptimizedFlashSuperTask> InitializeFromTasks(
            const FlashingPlan* fp, std::vector<std::unique_ptr<Task>>& tasks);
    using ImageEntry = std::pair<const Image*, std::string>;
    void Run() override;