From d25f1c377540ef4be3545b0e50e49be5df2ad09a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 9 Nov 2018 20:41:33 -0800 Subject: fastbootd: Support two super partitions for retrofit devices. Retrofit devices will have two super partitions, spanning the A and B slots separately. By design an OTA will never cause "A" or "B" partitions to be assigned to the wrong super. However, the same is not true of fastbootd, where it is possible to flash the inactive slot. We do not want, for example, logical "system_a" flashing to super_b. When interacting with partitions, fastbootd now extracts the slot suffix from a GetSuperSlotSuffix() helper. On retrofit devices, if the partition name has a slot, that slot will override FastbootDevice::GetCurrentSlot. This forces partitions in the inactive slot to be assigned to the correct super. There are two consequences of this. First, partitions with no slot suffix will default to the current slot. That means it is possible to wind up with two "scratch" partitions, if "adb remount" is used on both the "A" and "B" slots. However, only the active slot's "scratch" will be visible to the user (either through adb or fastboot). Second, if one slot does not have dynamic partitions, flashing will default to fixed partitions. For example, if the A slot is logical and B is not, flashing "system_a" will be logical and "system_b" will be fixed. This works no matter which slot is active. We do not try to upgrade the inactive slot to dynamic partitions. Bug: 116802789 Test: fastboot set_active a fastboot flashall # dynamic partitions fastboot getvar is-logical:system_a # true fastboot getvar is-logical:system_b # false fastboot set_active b fastboot flashall --skip-secondary fastboot getvar is-logical:system_a # true fastboot getvar is-logical:system_b # true Booting both slots works. Change-Id: Ib3c91944aaee1a96b2f5ad69c90e215bd6c5a2e8 --- fastboot/device/variables.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'fastboot/device/variables.cpp') diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 601af3446..130a3cf34 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -271,8 +271,7 @@ bool GetHasSlot(FastbootDevice* device, const std::vector& args, return true; } std::string partition_name = args[0] + slot_suffix; - if (FindPhysicalPartition(partition_name) || - LogicalPartitionExists(partition_name, slot_suffix)) { + if (FindPhysicalPartition(partition_name) || LogicalPartitionExists(device, partition_name)) { *message = "yes"; } else { *message = "no"; @@ -289,8 +288,7 @@ bool GetPartitionSize(FastbootDevice* device, const std::vector& ar // Zero-length partitions cannot be created through device-mapper, so we // special case them here. bool is_zero_length; - if (LogicalPartitionExists(args[0], device->GetCurrentSlot(), &is_zero_length) && - is_zero_length) { + if (LogicalPartitionExists(device, args[0], &is_zero_length) && is_zero_length) { *message = "0x0"; return true; } @@ -313,8 +311,7 @@ bool GetPartitionType(FastbootDevice* device, const std::vector& ar } std::string partition_name = args[0]; - if (!FindPhysicalPartition(partition_name) && - !LogicalPartitionExists(partition_name, device->GetCurrentSlot())) { + if (!FindPhysicalPartition(partition_name) && !LogicalPartitionExists(device, partition_name)) { *message = "Invalid partition"; return false; } @@ -363,7 +360,7 @@ bool GetPartitionIsLogical(FastbootDevice* device, const std::vectorGetCurrentSlot())) { + if (LogicalPartitionExists(device, partition_name)) { *message = "yes"; return true; } -- cgit v1.2.3