Pass in source slot to ctor of dynamic control
When DynamicPartitionControlAndroid is constructed, it initializes both
source and target slot to -1. These values get updated during
PreparePartitionsForUpdate call. And we only
PreparePartitionsForUpdate() when applying an OTA or applocating space
for an OTA(not when verifying OTA metadata). Which means if
VerifyPayloadApplicable() is called before any call two other APIs, we
could be using an "Uninitialiazed" dynamic partition control.
To mitigate this problem, we pass in source_slot at ctor of
DynamicPartitionControl, also make IsDynamicPartition() api take in a
slot number to avoid reading uninitialized member fields.
Bug: 181643302
Test: apply an OTA, abort, restart update_engine, verify a payload
Change-Id: I9a8a0fe8a9aca48e91241e15bdec33a1c1228553
diff --git a/common/dynamic_partition_control_interface.h b/common/dynamic_partition_control_interface.h
index 8b29c3b..da27932 100644
--- a/common/dynamic_partition_control_interface.h
+++ b/common/dynamic_partition_control_interface.h
@@ -170,7 +170,8 @@
const std::optional<std::string>&,
bool is_append = false) = 0;
- virtual bool IsDynamicPartition(const std::string& part_name) = 0;
+ virtual bool IsDynamicPartition(const std::string& part_name,
+ uint32_t slot) = 0;
// Create virtual block devices for all partitions.
virtual bool MapAllPartitions() = 0;