Reset slot switch before deleting snapshots am: f92fe255d2
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/2510838
Change-Id: I1bcbff6683d62d192127662c4289a2c47cec48b6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index e12678d..5628109 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -55,6 +55,7 @@
#include "update_engine/payload_consumer/payload_verifier.h"
#include "update_engine/payload_consumer/postinstall_runner_action.h"
#include "update_engine/update_boot_flags_action.h"
+#include "update_engine/update_status.h"
#include "update_engine/update_status_utils.h"
#ifndef _UE_SIDELOAD
@@ -427,6 +428,13 @@
return LogAndSetError(
error, FROM_HERE, "Already processing an update, cancel it first.");
}
+ if (status_ != UpdateStatus::IDLE &&
+ status_ != UpdateStatus::UPDATED_NEED_REBOOT) {
+ return LogAndSetError(error,
+ FROM_HERE,
+ "Status reset not allowed in this state, please "
+ "cancel on going OTA first.");
+ }
if (apex_handler_android_ != nullptr) {
LOG(INFO) << "Cleaning up reserved space for compressed APEX (if any)";
@@ -442,30 +450,18 @@
"Failed to reset the status because "
"ClearUpdateCompletedMarker() failed");
}
-
+ if (status_ == UpdateStatus::UPDATED_NEED_REBOOT) {
+ if (!resetShouldSwitchSlotOnReboot(error)) {
+ LOG(INFO) << "Failed to reset slot switch.";
+ return false;
+ }
+ LOG(INFO) << "Slot switch reset successful";
+ }
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: {
- return true;
- }
-
- case UpdateStatus::UPDATED_NEED_REBOOT: {
- const bool ret_value = resetShouldSwitchSlotOnReboot(error);
- if (ret_value) {
- LOG(INFO) << "Reset status successful";
- }
- return ret_value;
- }
-
- default:
- return LogAndSetError(
- error,
- FROM_HERE,
- "Reset not allowed in this state. Cancel the ongoing update first");
- }
+ return true;
}
bool UpdateAttempterAndroid::VerifyPayloadParseManifest(