Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "is_retrofit_device to work in bootloader" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zbw182 authored and Gerrit Code Review committed Sep 25, 2023
2 parents 911d309 + 5cbcdfa commit d774be9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions fastboot/fastboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,12 +1413,19 @@ void do_for_partitions(const std::string& part, const std::string& slot,
}
}

bool is_retrofit_device(fastboot::IFastBootDriver* fb) {
std::string value;
if (fb->GetVar("super-partition-name", &value) != fastboot::SUCCESS) {
bool is_retrofit_device(const ImageSource* source) {
// Does this device use dynamic partitions at all?
std::vector<char> contents;
if (!source->ReadFile("super_empty.img", &contents)) {
return false;
}
return android::base::StartsWith(value, "system_");
auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size());
for (const auto& partition : metadata->partitions) {
if (partition.attributes & LP_PARTITION_ATTR_SLOT_SUFFIXED) {
return true;
}
}
return false;
}

// Fetch a partition from the device to a given fd. This is a wrapper over FetchToFd to fetch
Expand Down Expand Up @@ -1876,7 +1883,7 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() {
// On these devices, secondary slots must be flashed as physical
// partitions (otherwise they would not mount on first boot). To enforce
// this, we delete any logical partitions for the "other" slot.
if (is_retrofit_device(fp_->fb)) {
if (is_retrofit_device(fp_->source)) {
std::string partition_name = image->part_name + "_" + slot;
if (image->IsSecondary() && should_flash_in_userspace(partition_name)) {
tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
Expand Down
2 changes: 1 addition & 1 deletion fastboot/fastboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int64_t get_sparse_limit(int64_t size, const FlashingPlan* fp);
std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size);

bool supports_AB(fastboot::IFastBootDriver* fb);
bool is_retrofit_device(fastboot::IFastBootDriver* fb);
bool is_retrofit_device(const ImageSource* source);
bool is_logical(const std::string& partition);
void fb_perform_format(const std::string& partition, int skip_if_not_supported,
const std::string& type_override, const std::string& size_override,
Expand Down

0 comments on commit d774be9

Please sign in to comment.