aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2022-03-17 07:04:40 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-17 07:04:40 +0000
commit04cf8c2164ea741b837894c802aa311df6ab6a97 (patch)
tree099d0a466823ba393783dfef4ea083d46ab7bb75
parent29ef9adbdcf6aeb03e21670b5ef5cdf1e57449a0 (diff)
parent443883daeb73aafd6129bb2fd02bf9b1fa9578c0 (diff)
downloadupdate_engine-04cf8c2164ea741b837894c802aa311df6ab6a97.tar.gz
Fully reset update state during ResetStatus() call am: ff5380b76a am: 294a321c2a am: 443883daeb
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/2029085 Change-Id: Ie2b2fb06b2925a1f36ab15995157576fb6508142
-rw-r--r--aosp/dynamic_partition_control_android.cc6
-rw-r--r--aosp/dynamic_partition_control_android.h6
-rw-r--r--aosp/update_attempter_android.cc12
3 files changed, 18 insertions, 6 deletions
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index 6d33a09a..e39e7bc7 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -465,6 +465,9 @@ bool DynamicPartitionControlAndroid::PreparePartitionsForUpdate(
if (!SetTargetBuildVars(manifest)) {
return false;
}
+ for (auto& list : dynamic_partition_list_) {
+ list.clear();
+ }
// Although the current build supports dynamic partitions, the given payload
// doesn't use it for target partitions. This could happen when applying a
@@ -1280,6 +1283,9 @@ bool DynamicPartitionControlAndroid::ResetUpdate(PrefsInterface* prefs) {
if (!GetVirtualAbFeatureFlag().IsEnabled()) {
return true;
}
+ for (auto& list : dynamic_partition_list_) {
+ list.clear();
+ }
LOG(INFO) << __func__ << " resetting update state and deleting snapshots.";
TEST_AND_RETURN_FALSE(prefs != nullptr);
diff --git a/aosp/dynamic_partition_control_android.h b/aosp/dynamic_partition_control_android.h
index cebca07f..457ef182 100644
--- a/aosp/dynamic_partition_control_android.h
+++ b/aosp/dynamic_partition_control_android.h
@@ -21,7 +21,7 @@
#include <set>
#include <string>
#include <string_view>
-#include <vector>
+#include <array>
#include <base/files/file_util.h>
#include <libsnapshot/auto_device.h>
@@ -348,7 +348,9 @@ class DynamicPartitionControlAndroid : public DynamicPartitionControlInterface {
uint32_t source_slot_ = UINT32_MAX;
uint32_t target_slot_ = UINT32_MAX;
- std::vector<std::vector<std::string>> dynamic_partition_list_{2UL};
+ // We assume that there's only 2 slots, A and B. This assumption is unlikely
+ // to change in the future. And certaintly won't change at runtime.
+ std::array<std::vector<std::string>, 2> dynamic_partition_list_{};
DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
};
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 4e609d4e..a3485eac 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -400,6 +400,10 @@ bool UpdateAttempterAndroid::CancelUpdate(brillo::ErrorPtr* error) {
bool UpdateAttempterAndroid::ResetStatus(brillo::ErrorPtr* error) {
LOG(INFO) << "Attempting to reset state from "
<< UpdateStatusToString(status_) << " to UpdateStatus::IDLE";
+ if (processor_->IsRunning()) {
+ return LogAndSetError(
+ error, FROM_HERE, "Already processing an update, cancel it first.");
+ }
if (apex_handler_android_ != nullptr) {
LOG(INFO) << "Cleaning up reserved space for compressed APEX (if any)";
@@ -416,12 +420,12 @@ bool UpdateAttempterAndroid::ResetStatus(brillo::ErrorPtr* error) {
"ClearUpdateCompletedMarker() failed");
}
+ if (!boot_control_->GetDynamicPartitionControl()->ResetUpdate(prefs_)) {
+ LOG(WARNING) << "Failed to reset snapshots. UpdateStatus is IDLE but"
+ << "space might not be freed.";
+ }
switch (status_) {
case UpdateStatus::IDLE: {
- if (!boot_control_->GetDynamicPartitionControl()->ResetUpdate(prefs_)) {
- LOG(WARNING) << "Failed to reset snapshots. UpdateStatus is IDLE but"
- << "space might not be freed.";
- }
return true;
}