Call InitPartitionMetadata when resuming an update.
BootControlAndroid::InitPartitionMetadata() should always be called when
starting / resuming an update that uses dynamic partitions. This allows
updating the metadata for the target slot, as well as setting up the
internal state for accessing the dynamic partitions in the target slot.
Bug: 122097567
Test: Run update_engine_unittests on taimen and blueline.
Test: Apply a payload that uses dynamic partitions. Reboot before it
finishes, then resume the update.
Change-Id: I1353f7460a61c0183654b6349689beaa9bf12129
diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h
index 43517ce..392d785 100644
--- a/common/boot_control_interface.h
+++ b/common/boot_control_interface.h
@@ -66,7 +66,9 @@
// Determines the block device for the given partition name and slot number.
// The |slot| number must be between 0 and GetNumSlots() - 1 and the
// |partition_name| is a platform-specific name that identifies a partition on
- // every slot. On success, returns true and stores the block device in
+ // every slot. In order to access the dynamic partitions in the target slot,
+ // InitPartitionMetadata() must be called (once per payload) prior to calling
+ // this function. On success, returns true and stores the block device in
// |device|.
virtual bool GetPartitionDevice(const std::string& partition_name,
Slot slot,
@@ -92,14 +94,14 @@
// of the operation.
virtual bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) = 0;
- // Initialize metadata of underlying partitions for a given |slot|.
- // Ensure that all updateable groups with the suffix GetSuffix(|slot|) exactly
- // matches the layout specified in |partition_metadata|. Ensure that
- // partitions at the specified |slot| has a given size and updateable group,
- // as specified by |partition_metadata|. Sizes must be aligned to the logical
- // block size of the super partition.
+ // Initializes the metadata of the underlying partitions for a given |slot|
+ // and sets up the states for accessing dynamic partitions.
+ // |partition_metadata| will be written to the specified |slot| if
+ // |update_metadata| is set.
virtual bool InitPartitionMetadata(
- Slot slot, const PartitionMetadata& partition_metadata) = 0;
+ Slot slot,
+ const PartitionMetadata& partition_metadata,
+ bool update_metadata) = 0;
// Do necessary clean-up operations after the whole update.
virtual void Cleanup() = 0;
diff --git a/common/boot_control_stub.cc b/common/boot_control_stub.cc
index ca880d4..0fe8a98 100644
--- a/common/boot_control_stub.cc
+++ b/common/boot_control_stub.cc
@@ -60,7 +60,9 @@
}
bool BootControlStub::InitPartitionMetadata(
- Slot slot, const PartitionMetadata& partition_metadata) {
+ Slot slot,
+ const PartitionMetadata& partition_metadata,
+ bool update_metadata) {
LOG(ERROR) << __FUNCTION__ << " should never be called.";
return false;
}
diff --git a/common/boot_control_stub.h b/common/boot_control_stub.h
index 0950997..8dfaffc 100644
--- a/common/boot_control_stub.h
+++ b/common/boot_control_stub.h
@@ -45,8 +45,9 @@
bool MarkSlotUnbootable(BootControlInterface::Slot slot) override;
bool SetActiveBootSlot(BootControlInterface::Slot slot) override;
bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override;
- bool InitPartitionMetadata(
- Slot slot, const PartitionMetadata& partition_metadata) override;
+ bool InitPartitionMetadata(Slot slot,
+ const PartitionMetadata& partition_metadata,
+ bool update_metadata) override;
void Cleanup() override;
private:
diff --git a/common/constants.cc b/common/constants.cc
index 3ae7a60..310f1b2 100644
--- a/common/constants.cc
+++ b/common/constants.cc
@@ -37,8 +37,8 @@
const char kPrefsDailyMetricsLastReportedAt[] =
"daily-metrics-last-reported-at";
const char kPrefsDeltaUpdateFailures[] = "delta-update-failures";
-const char kPrefsDynamicPartitionMetadataInitialized[] =
- "dynamic-partition-metadata-initialized";
+const char kPrefsDynamicPartitionMetadataUpdated[] =
+ "dynamic-partition-metadata-updated";
const char kPrefsFullPayloadAttemptNumber[] = "full-payload-attempt-number";
const char kPrefsInstallDateDays[] = "install-date-days";
const char kPrefsLastActivePingDay[] = "last-active-ping-day";
diff --git a/common/constants.h b/common/constants.h
index 61e5ddd..d5a8ae3 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -41,7 +41,7 @@
extern const char kPrefsCurrentUrlIndex[];
extern const char kPrefsDailyMetricsLastReportedAt[];
extern const char kPrefsDeltaUpdateFailures[];
-extern const char kPrefsDynamicPartitionMetadataInitialized[];
+extern const char kPrefsDynamicPartitionMetadataUpdated[];
extern const char kPrefsFullPayloadAttemptNumber[];
extern const char kPrefsInstallDateDays[];
extern const char kPrefsLastActivePingDay[];
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 513c149..ba975a2 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -74,8 +74,9 @@
return true;
}
- bool InitPartitionMetadata(
- Slot slot, const PartitionMetadata& partition_metadata) override {
+ bool InitPartitionMetadata(Slot slot,
+ const PartitionMetadata& partition_metadata,
+ bool update_metadata) override {
return true;
}