Adding parsing for fastboot-info
Adding back the parsing for fastboot info Test: m fastboot, fastboot flashall Change-Id: I0075266bad5d45dcb99dbf91aa431008ca336216
This commit is contained in:
parent
3e04857a59
commit
c97eeed5e4
2 changed files with 32 additions and 3 deletions
|
@ -173,7 +173,7 @@ static std::vector<Image> images = {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
static char* get_android_product_out() {
|
||||
char* get_android_product_out() {
|
||||
char* dir = getenv("ANDROID_PRODUCT_OUT");
|
||||
if (dir == nullptr || dir[0] == '\0') {
|
||||
return nullptr;
|
||||
|
@ -1787,13 +1787,25 @@ void FlashAllTool::Flash() {
|
|||
|
||||
CancelSnapshotIfNeeded();
|
||||
|
||||
tasks_ = CollectTasksFromImageList();
|
||||
tasks_ = CollectTasks();
|
||||
for (auto& task : tasks_) {
|
||||
task->Run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() {
|
||||
std::vector<std::unique_ptr<Task>> tasks;
|
||||
if (fp_->should_use_fastboot_info) {
|
||||
tasks = CollectTasksFromFastbootInfo();
|
||||
|
||||
} else {
|
||||
tasks = CollectTasksFromImageList();
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void FlashAllTool::CheckRequirements() {
|
||||
std::vector<char> contents;
|
||||
if (!fp_->source->ReadFile("android-info.txt", &contents)) {
|
||||
|
@ -1848,7 +1860,6 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() {
|
|||
// or in bootloader fastboot.
|
||||
std::vector<std::unique_ptr<Task>> tasks;
|
||||
AddFlashTasks(boot_images_, tasks);
|
||||
|
||||
if (auto flash_super_task = OptimizedFlashSuperTask::Initialize(fp_, os_images_)) {
|
||||
tasks.emplace_back(std::move(flash_super_task));
|
||||
} else {
|
||||
|
@ -1871,10 +1882,23 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() {
|
|||
tasks.emplace_back(std::make_unique<ResizeTask>(fp_, image->part_name, "0", slot));
|
||||
}
|
||||
}
|
||||
|
||||
AddFlashTasks(os_images_, tasks);
|
||||
return tasks;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromFastbootInfo() {
|
||||
std::vector<std::unique_ptr<Task>> tasks;
|
||||
std::vector<char> contents;
|
||||
if (!fp_->source->ReadFile("fastboot-info.txt", &contents)) {
|
||||
LOG(VERBOSE) << "Flashing from hardcoded images. fastboot-info.txt is empty or does not "
|
||||
"exist";
|
||||
return CollectTasksFromImageList();
|
||||
}
|
||||
tasks = ParseFastbootInfo(fp_, Split({contents.data(), contents.size()}, "\n"));
|
||||
return tasks;
|
||||
}
|
||||
|
||||
void FlashAllTool::AddFlashTasks(const std::vector<std::pair<const Image*, std::string>>& images,
|
||||
std::vector<std::unique_ptr<Task>>& tasks) {
|
||||
for (const auto& [image, slot] : images) {
|
||||
|
|
|
@ -97,6 +97,7 @@ struct FlashingPlan {
|
|||
bool skip_secondary = false;
|
||||
bool force_flash = false;
|
||||
bool should_optimize_flash_super = true;
|
||||
bool should_use_fastboot_info = false;
|
||||
uint64_t sparse_limit = 0;
|
||||
|
||||
std::string slot_override;
|
||||
|
@ -111,6 +112,7 @@ class FlashAllTool {
|
|||
FlashAllTool(FlashingPlan* fp);
|
||||
|
||||
void Flash();
|
||||
std::vector<std::unique_ptr<Task>> CollectTasks();
|
||||
|
||||
private:
|
||||
void CheckRequirements();
|
||||
|
@ -118,6 +120,8 @@ class FlashAllTool {
|
|||
void CollectImages();
|
||||
void AddFlashTasks(const std::vector<std::pair<const Image*, std::string>>& images,
|
||||
std::vector<std::unique_ptr<Task>>& tasks);
|
||||
|
||||
std::vector<std::unique_ptr<Task>> CollectTasksFromFastbootInfo();
|
||||
std::vector<std::unique_ptr<Task>> CollectTasksFromImageList();
|
||||
|
||||
std::vector<ImageEntry> boot_images_;
|
||||
|
@ -143,6 +147,7 @@ class LocalImageSource final : public ImageSource {
|
|||
unique_fd OpenFile(const std::string& name) const override;
|
||||
};
|
||||
|
||||
char* get_android_product_out();
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue