Fix sideload OTA breakage
MapAllPartitions doesn't work in recovery, which prevented slot switch.
A logic error in code prevented this from being reporeted correctly, so
device proceeded to reboot thinking that OTA is successful, even though
slot isn't switched.
Bug: 320206874
Test: sideload an recovery OTA
Change-Id: Ief560ef8c3eddc1162d784f1bb03bf9c76c3d8eb
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 2cfd3c6..bfdd39e 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -36,6 +36,8 @@
#include "update_engine/common/action_processor.h"
#include "update_engine/common/boot_control_interface.h"
+#include "update_engine/common/error_code_utils.h"
+#include "update_engine/common/platform_constants.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/utils.h"
@@ -443,7 +445,8 @@
DEFER {
if (error_code != ErrorCode::kSuccess &&
error_code != ErrorCode::kUpdatedButNotActive) {
- LOG(ERROR) << "Postinstall action failed.";
+ LOG(ERROR) << "Postinstall action failed. "
+ << utils::ErrorCodeToString(error_code);
// Undo any changes done to trigger Powerwash.
if (powerwash_scheduled_)
@@ -453,10 +456,13 @@
};
if (error_code == ErrorCode::kSuccess) {
if (install_plan_.switch_slot_on_reboot) {
- if (!boot_control_->GetDynamicPartitionControl()->MapAllPartitions()) {
- LOG(ERROR) << "Failed to map all partitions before marking snapshot as "
- "ready for slot switch.";
- return;
+ if constexpr (!constants::kIsRecovery) {
+ if (!boot_control_->GetDynamicPartitionControl()->MapAllPartitions()) {
+ LOG(WARNING)
+ << "Failed to map all partitions before marking snapshot as "
+ "ready for slot switch. Subsequent FinishUpdate() call may or "
+ "may not work";
+ }
}
if (!boot_control_->GetDynamicPartitionControl()->FinishUpdate(
install_plan_.powerwash_required) ||