summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2022-06-22 10:18:54 -0700
committerAkilesh Kailash <akailash@google.com>2022-06-28 00:31:16 +0000
commit2a8f89270f04d3a7b3f77f86e178d7c2edf48d89 (patch)
treed0771fbbb456fca95239ccb96ffa00aaea6eaf58
parent4f39da8e8db32fb8e0aed5ec8734b6be22e0eadb (diff)
Fix partition mapping bug
After installing a VABC OTA and device reboots, merge happens. Some OTA states are cached in memory during the merge process. When the 2nd OTA comes, update_engine will incorrectly think the 2nd OTA is also a VABC update, resulting in incorrectly mapped partitions. Then update_engine will extract data from OTA and write them to source partitions, causing verity error and bricking the device. This CL fixes the corruption bug by create a new instance of SnapshotManager for each new OTA. This prevents us from reading stale data cached in SnapshotManager member variables. Bug: 229708688 Bug: 236348265 Test: Apply VABC OTA, reboot, then apply VAB OTA Change-Id: If4d1de8393ce0329b825c06e567b985e9d89680b (cherry picked from commit c675fc0aaa6f9e4d88d040847435f2487ff9a2d3) Merged-In: If4d1de8393ce0329b825c06e567b985e9d89680b
-rw-r--r--aosp/dynamic_partition_control_android.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index 27d1d541..334ccdc2 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -98,7 +98,8 @@ constexpr std::chrono::milliseconds kMapTimeout{1000};
constexpr std::chrono::milliseconds kMapSnapshotTimeout{10000};
DynamicPartitionControlAndroid::~DynamicPartitionControlAndroid() {
- Cleanup();
+ UnmapAllPartitions();
+ metadata_device_.reset();
}
static FeatureFlag GetFeatureFlag(const char* enable_prop,
@@ -312,6 +313,12 @@ bool DynamicPartitionControlAndroid::UnmapAllPartitions() {
void DynamicPartitionControlAndroid::Cleanup() {
UnmapAllPartitions();
metadata_device_.reset();
+ if (GetVirtualAbFeatureFlag().IsEnabled()) {
+ snapshot_ = SnapshotManager::New();
+ } else {
+ snapshot_ = SnapshotManagerStub::New();
+ }
+ CHECK(snapshot_ != nullptr) << "Cannot initialize SnapshotManager.";
}
bool DynamicPartitionControlAndroid::DeviceExists(const std::string& path) {