Fix issues with setShouldSwitchSlotOnReboot am: e227d99de3 am: 0e29c0ba75

Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/3339347

Change-Id: I1d64a56af02b1f7e1533f4bb997b3d7007ccb0de
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 6b05603..9f7ec97 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -506,6 +506,10 @@
         "Status reset not allowed in this state, please "
         "cancel on going OTA first.");
   }
+  // last_error_ is used by setShouldSwitchSlot to determine if
+  // FilesystemVerification is done. Since we are discarding update
+  // state, discard this cache as well.
+  last_error_ = ErrorCode::kSuccess;
 
   if (apex_handler_android_ != nullptr) {
     LOG(INFO) << "Cleaning up reserved space for compressed APEX (if any)";
@@ -1339,6 +1343,9 @@
   // Don't run postinstall, we just need PostinstallAction to switch the slots.
   install_plan_.run_post_install = false;
   install_plan_.is_resume = true;
+  // previous ApplyPayload() call may have requested powerwash, these
+  // settings would be saved in `this->install_plan_`. Inherit that setting.
+  install_plan_.powerwash_required = this->install_plan_.powerwash_required;
 
   CHECK_NE(install_plan_.source_slot, UINT32_MAX);
   CHECK_NE(install_plan_.target_slot, UINT32_MAX);