Don't unmap partitions if they weren't mapped
When calling setShouldSwitchSlotOnReboot(), we will run postinstall
action, but don't map any partitions. Avoid calling Unmap() in this
case.
Test: th
Bug: 269397263
Change-Id: Icbd994bc9ba6b106c1b8256ff75eaf52a8d38d86
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 25736ee..6beca56 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -202,7 +202,7 @@
void PostinstallRunnerAction::PerformPartitionPostinstall() {
if (install_plan_.download_url.empty()) {
- LOG(INFO) << "Skipping post-install during rollback";
+ LOG(INFO) << "Skipping post-install";
return CompletePostinstall(ErrorCode::kSuccess);
}
@@ -430,6 +430,12 @@
}
void PostinstallRunnerAction::CompletePostinstall(ErrorCode error_code) {
+ if (!install_plan_.partitions.empty()) {
+ auto dynamic_control = boot_control_->GetDynamicPartitionControl();
+ CHECK(dynamic_control);
+ dynamic_control->UnmapAllPartitions();
+ LOG(INFO) << "Unmapped all partitions.";
+ }
// We only attempt to mark the new slot as active if all the postinstall
// steps succeeded.
if (error_code == ErrorCode::kSuccess) {
@@ -449,11 +455,6 @@
}
}
- auto dynamic_control = boot_control_->GetDynamicPartitionControl();
- CHECK(dynamic_control);
- dynamic_control->UnmapAllPartitions();
- LOG(INFO) << "Unmapped all partitions.";
-
ScopedActionCompleter completer(processor_, this);
completer.set_code(error_code);