summaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-11-28 17:10:42 -0800
committerDavid Anderson <dvander@google.com>2018-11-28 17:47:21 -0800
commit0c73234fe00f638eb455e13f5b8917a1f2e33849 (patch)
treebcb77482c0b44e91be5311c2eca71b96123ae07f /fastboot
parent4055587ddd117dd9851e47ad056425604bb3afed (diff)
downloadsystem_core-0c73234fe00f638eb455e13f5b8917a1f2e33849.tar.gz
system_core-0c73234fe00f638eb455e13f5b8917a1f2e33849.tar.bz2
system_core-0c73234fe00f638eb455e13f5b8917a1f2e33849.zip
fastboot: Delete logical "other" partitions on retrofit devices.
On retrofit devices, if both slots contain dynamic partition builds, then "flashall" will attempt to write secondary images to dynamic partitions in the other slot. At worst, this can fail with an error. At best, it will result in the "other" partition not being mounted on first boot. This patch therefore deletes logical partitions for secondary images, on retrofit devices only. On a Pixel device on the "b" slot, this means "system_a" and "vendor_a" will be deleted before flashing, and therefore system_other and vendor_other will be flashed to physical partitions instead. Bug: 120034852 Test: fastboot set_active a fastboot flashall fastboot set_active b fastboot flashall Change-Id: I6affe9a6c639b0495bffc77fcf20f329b86ad159
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/fastboot.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 0978ec13e..fee08577c 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -46,6 +46,7 @@
#include <chrono>
#include <functional>
#include <regex>
+#include <string>
#include <thread>
#include <utility>
#include <vector>
@@ -78,6 +79,7 @@ using android::base::ReadFully;
using android::base::Split;
using android::base::Trim;
using android::base::unique_fd;
+using namespace std::string_literals;
static const char* serial = nullptr;
@@ -1106,6 +1108,14 @@ static bool is_logical(const std::string& partition) {
return fb->GetVar("is-logical:" + partition, &value) == fastboot::SUCCESS && value == "yes";
}
+static bool is_retrofit_device() {
+ std::string value;
+ if (fb->GetVar("super-partition-name", &value) != fastboot::SUCCESS) {
+ return false;
+ }
+ return android::base::StartsWith(value, "system_");
+}
+
static void do_flash(const char* pname, const char* fname) {
struct fastboot_buffer buf;
@@ -1319,6 +1329,19 @@ void FlashAllTool::UpdateSuperPartition() {
command += ":wipe";
}
fb->RawCommand(command, "Updating super partition");
+
+ // Retrofit devices have two super partitions, named super_a and super_b.
+ // 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()) {
+ for (const auto& [image, slot] : os_images_) {
+ std::string partition_name = image->part_name + "_"s + slot;
+ if (image->IsSecondary() && is_logical(partition_name)) {
+ fb->DeletePartition(partition_name);
+ }
+ }
+ }
}
class ZipImageSource final : public ImageSource {