DynamicPartitionControl: support retrofit devices
On retrofit devices:
* The retrofit update includes block devices at source
slot (for example, system_a, vendor_a, product_a).
This is done automatically because the retrofit update
does not look different from regular updates in OTA
client's perspective.
* The first update after the retrofit update includes
the rest of the block devices (in the above example,
system_b, vendor_b and product_b).
In order to do the second,
* use NewForUpdate() API from liblp to automatically
include block devices at the target slot when the metadata
is loaded.
* Use FlashPartitionTable() API to flash metadata to system_b
directly without reading existing metadata from it.
Test: manual OTA on retrofit devices
Bug: 118506262
Change-Id: Ib2c15b8a1a04271320bfef408813723a5b2a7bd7
diff --git a/boot_control_android_unittest.cc b/boot_control_android_unittest.cc
index e98d2f4..6460ffe 100644
--- a/boot_control_android_unittest.cc
+++ b/boot_control_android_unittest.cc
@@ -298,10 +298,12 @@
}
void SetMetadata(uint32_t slot, const PartitionMetadata& metadata) {
- EXPECT_CALL(dynamicControl(), LoadMetadataBuilder(GetSuperDevice(), slot))
+ EXPECT_CALL(dynamicControl(),
+ LoadMetadataBuilder(GetSuperDevice(), slot, _))
.Times(AnyNumber())
- .WillRepeatedly(Invoke(
- [metadata](auto, auto) { return NewFakeMetadata(metadata); }));
+ .WillRepeatedly(Invoke([metadata](auto, auto, auto) {
+ return NewFakeMetadata(metadata);
+ }));
}
// Expect that MapPartitionOnDeviceMapper is called on target() metadata slot
@@ -394,7 +396,7 @@
.Times(0);
// Should not load metadata from target slot.
EXPECT_CALL(dynamicControl(),
- LoadMetadataBuilder(GetSuperDevice(), target()))
+ LoadMetadataBuilder(GetSuperDevice(), target(), _))
.Times(0);
}
@@ -512,8 +514,9 @@
// Test corrupt source metadata case.
TEST_P(BootControlAndroidTestP, CorruptedSourceMetadata) {
- EXPECT_CALL(dynamicControl(), LoadMetadataBuilder(GetSuperDevice(), source()))
- .WillOnce(Invoke([](auto, auto) { return nullptr; }));
+ EXPECT_CALL(dynamicControl(),
+ LoadMetadataBuilder(GetSuperDevice(), source(), _))
+ .WillOnce(Invoke([](auto, auto, auto) { return nullptr; }));
EXPECT_FALSE(InitPartitionMetadata(target(), {{"system", 1_GiB}}))
<< "Should not be able to continue with corrupt source metadata";
}