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

Commit 475ffb84 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revert "Cleaned up some slot logic"" am: b2fdbef4

parents fa81e504 b2fdbef4
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -1560,10 +1560,10 @@ static void CancelSnapshotIfNeeded() {
    }
}

std::string GetPartitionName(const ImageEntry& entry) {
std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot) {
    auto slot = entry.second;
    if (slot.empty()) {
        slot = get_current_slot();
        slot = current_slot;
    }
    if (slot.empty()) {
        return entry.first->part_name;
@@ -1582,7 +1582,7 @@ class FlashAllTool {

  private:
    void CheckRequirements();
    void DetermineSecondarySlot();
    void DetermineSlot();
    void CollectImages();
    void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images);
    void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf);
@@ -1600,13 +1600,15 @@ void FlashAllTool::Flash() {

    // Change the slot first, so we boot into the correct recovery image when
    // using fastbootd.
    if (fp_->slot_override == "all") {
    if (fp_->slot == "all") {
        set_active("a");
    } else {
        set_active(fp_->slot_override);
        set_active(fp_->slot);
    }

    DetermineSecondarySlot();
    DetermineSlot();
    CollectImages();

    CancelSnapshotIfNeeded();

    // First flash boot partitions. We allow this to happen either in userspace
@@ -1651,12 +1653,18 @@ void FlashAllTool::CheckRequirements() {
    ::CheckRequirements({contents.data(), contents.size()}, fp_->force_flash);
}

void FlashAllTool::DetermineSecondarySlot() {
void FlashAllTool::DetermineSlot() {
    if (fp_->slot.empty()) {
        fp_->current_slot = get_current_slot();
    } else {
        fp_->current_slot = fp_->slot;
    }

    if (fp_->skip_secondary) {
        return;
    }
    if (fp_->slot_override != "" && fp_->slot_override != "all") {
        fp_->secondary_slot = get_other_slot(fp_->slot_override);
    if (fp_->slot != "" && fp_->slot != "all") {
        fp_->secondary_slot = get_other_slot(fp_->slot);
    } else {
        fp_->secondary_slot = get_other_slot();
    }
@@ -1670,7 +1678,7 @@ void FlashAllTool::DetermineSecondarySlot() {

void FlashAllTool::CollectImages() {
    for (size_t i = 0; i < images.size(); ++i) {
        std::string slot = fp_->slot_override;
        std::string slot = fp_->slot;
        if (images[i].IsSecondary()) {
            if (fp_->skip_secondary) {
                continue;
+3 −2
Original line number Diff line number Diff line
@@ -80,7 +80,8 @@ struct FlashingPlan {
    bool skip_secondary = false;
    bool force_flash = false;

    std::string slot_override;
    std::string slot;
    std::string current_slot;
    std::string secondary_slot;
    fastboot::FastBootDriver* fb;
};
@@ -102,7 +103,7 @@ struct NetworkSerial {

Result<NetworkSerial, FastbootError> ParseNetworkSerial(const std::string& serial);
bool supports_AB();
std::string GetPartitionName(const ImageEntry& entry);
std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot_);
void flash_partition_files(const std::string& partition, const std::vector<SparsePtr>& files);
int64_t get_sparse_limit(int64_t size);
std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size);
+3 −3
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
        LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device";
        return nullptr;
    }
    if (fp->slot_override == "all") {
    if (fp->slot == "all") {
        LOG(VERBOSE) << "Cannot optimize flashing super for all slots";
        return nullptr;
    }
@@ -132,7 +132,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
    }

    for (const auto& entry : os_images) {
        auto partition = GetPartitionName(entry);
        auto partition = GetPartitionName(entry, fp->current_slot);
        auto image = entry.first;

        if (!helper->AddPartition(partition, image->img_name, image->optional_if_no_image)) {
@@ -145,7 +145,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(

    // Remove images that we already flashed, just in case we have non-dynamic OS images.
    auto remove_if_callback = [&](const ImageEntry& entry) -> bool {
        return helper->WillFlash(GetPartitionName(entry));
        return helper->WillFlash(GetPartitionName(entry, fp->current_slot));
    };
    os_images.erase(std::remove_if(os_images.begin(), os_images.end(), remove_if_callback),
                    os_images.end());