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

Commit a589bec2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9786938 from 14850162 to udc-release

Change-Id: Ib0336a00b05692afde6ec4ce4542ebbbbcc880b2
parents 3b55030d 14850162
Loading
Loading
Loading
Loading
+11 −26
Original line number Diff line number Diff line
@@ -1202,10 +1202,9 @@ static uint64_t get_partition_size(const std::string& partition) {
}

static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) {
    if (buf->sz < AVB_FOOTER_SIZE) {
    if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition)) {
        return;
    }

    // If overflows and negative, it should be < buf->sz.
    int64_t partition_size = static_cast<int64_t>(get_partition_size(partition));

@@ -1259,11 +1258,7 @@ void flash_partition_files(const std::string& partition, const std::vector<Spars

static void flash_buf(const std::string& partition, struct fastboot_buffer* buf,
                      const bool apply_vbmeta) {
    if (partition == "boot" || partition == "boot_a" || partition == "boot_b" ||
        partition == "init_boot" || partition == "init_boot_a" || partition == "init_boot_b" ||
        partition == "recovery" || partition == "recovery_a" || partition == "recovery_b") {
    copy_avb_footer(partition, buf);
    }

    // Rewrite vbmeta if that's what we're flashing and modification has been requested.
    if (g_disable_verity || g_disable_verification) {
@@ -1593,11 +1588,6 @@ class FlashAllTool {
    void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images);
    void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf);

    // If the image uses the default slot, or the user specified "all", then
    // the paired string will be empty. If the image requests a specific slot
    // (for example, system_other) it is specified instead.
    using ImageEntry = std::pair<const Image*, std::string>;

    std::vector<ImageEntry> boot_images_;
    std::vector<ImageEntry> os_images_;
    FlashingPlan* fp_;
@@ -1626,17 +1616,15 @@ void FlashAllTool::Flash() {
    // or in bootloader fastboot.
    FlashImages(boot_images_);

    auto flash_super_task = FlashSuperLayoutTask::Initialize(fp_, os_images_);
    std::vector<std::unique_ptr<Task>> tasks;

    if (flash_super_task) {
        flash_super_task->Run();
    if (auto flash_super_task = FlashSuperLayoutTask::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.
        std::unique_ptr<UpdateSuperTask> update_super_task = std::make_unique<UpdateSuperTask>(fp_);
        update_super_task->Run();
        tasks.emplace_back(std::make_unique<UpdateSuperTask>(fp_));
        // Resize any logical partition to 0, so each partition is reset to 0
        // extents, and will achieve more optimal allocation.
        std::vector<std::unique_ptr<ResizeTask>> resize_tasks;
        for (const auto& [image, slot] : os_images_) {
            // Retrofit devices have two super partitions, named super_a and super_b.
            // On these devices, secondary slots must be flashed as physical
@@ -1646,17 +1634,14 @@ void FlashAllTool::Flash() {
                std::string partition_name = image->part_name + "_"s + slot;
                if (image->IsSecondary() && is_logical(partition_name)) {
                    fp_->fb->DeletePartition(partition_name);
                    std::unique_ptr<DeleteTask> delete_task =
                            std::make_unique<DeleteTask>(fp_, partition_name);
                    delete_task->Run();
                }
                tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
            }
            resize_tasks.emplace_back(
                    std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
            tasks.emplace_back(std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
        }
        for (auto& i : resize_tasks) {
            i->Run();
    }
    for (auto& task : tasks) {
        task->Run();
    }
    FlashImages(os_images_);
}
+0 −5
Original line number Diff line number Diff line
@@ -20,11 +20,6 @@
#include "super_flash_helper.h"

using namespace std::string_literals;

FlashTask::FlashTask(const std::string& slot, const std::string& pname, const bool apply_vbmeta)
    : pname_(pname), fname_(find_item(pname)), slot_(slot), apply_vbmeta_(apply_vbmeta) {
    if (fname_.empty()) die("cannot determine image filename for '%s'", pname_.c_str());
}
FlashTask::FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname,
                     const bool apply_vbmeta)
    : pname_(_pname), fname_(_fname), slot_(_slot), apply_vbmeta_(apply_vbmeta) {}
+0 −1
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ class Task {

class FlashTask : public Task {
  public:
    FlashTask(const std::string& slot, const std::string& pname, const bool apply_vbmeta);
    FlashTask(const std::string& slot, const std::string& pname, const std::string& fname,
              const bool apply_vbmeta);

+14 −5
Original line number Diff line number Diff line
@@ -260,8 +260,8 @@ unsigned int sparse_file_block_size(struct sparse_file* s) {
  return s->block_size;
}

static struct backed_block* move_chunks_up_to_len(struct sparse_file* from, struct sparse_file* to,
                                                  unsigned int len) {
static int move_chunks_up_to_len(struct sparse_file* from, struct sparse_file* to, unsigned int len,
                                 backed_block** out_bb) {
  int64_t count = 0;
  struct output_file* out_counter;
  struct backed_block* last_bb = nullptr;
@@ -282,7 +282,7 @@ static struct backed_block* move_chunks_up_to_len(struct sparse_file* from, stru
  out_counter = output_file_open_callback(out_counter_write, &count, to->block_size, to->len, false,
                                          true, 0, false);
  if (!out_counter) {
    return nullptr;
    return -1;
  }

  for (bb = start; bb; bb = backed_block_iter_next(bb)) {
@@ -319,7 +319,8 @@ move:
out:
  output_file_close(out_counter);

  return bb;
  *out_bb = bb;
  return 0;
}

int sparse_file_resparse(struct sparse_file* in_s, unsigned int max_len, struct sparse_file** out_s,
@@ -337,7 +338,15 @@ int sparse_file_resparse(struct sparse_file* in_s, unsigned int max_len, struct
  do {
    s = sparse_file_new(in_s->block_size, in_s->len);

    bb = move_chunks_up_to_len(in_s, s, max_len);
    if (move_chunks_up_to_len(in_s, s, max_len, &bb) < 0) {
      sparse_file_destroy(s);
      for (int i = 0; i < c && i < out_s_count; i++) {
        sparse_file_destroy(out_s[i]);
        out_s[i] = nullptr;
      }
      sparse_file_destroy(tmp);
      return -1;
    }

    if (c < out_s_count) {
      out_s[c] = s;
+5 −0
Original line number Diff line number Diff line
@@ -28,5 +28,10 @@ void Counter::logIncrement(const char* metricName, int64_t amount) {
    stats_write(EXPRESS_EVENT_REPORTED, metricIdHash, amount);
}

void Counter::logIncrementWithUid(const char* metricName, int32_t uid, int64_t amount) {
    const int64_t metricIdHash = farmhash::Fingerprint64(metricName, strlen(metricName));
    stats_write(EXPRESS_UID_EVENT_REPORTED, metricIdHash, amount, uid);
}

}  // namespace expresslog
}  // namespace android
Loading