Clean up reserved space for decompression when OTA cancelled
OTA can terminate in the following ways:
1) Before reboot, intentionally cancelled.
2) Before reboot, failed due to error
3) After reboot, failed due to error
4) After reboot, success
Cleaning up from ResetStatus should cover #1. For #2, there won't be
automatic cleanup on failure, as sometimes we resume OTA from where it
last failed. So user needs to explicitely call ResetStatus to clean up.
for #2.
Number #3 and #4 will be dealt in follow up cl.
Bug: 172911822
Test: Case #1: Intentionally cancel
1. Allocated space:
python3 update_device.py --allocate-only ota.zip
2. Temp file deleted by:
adb shell update_engine_client --reset_status
Change-Id: Id6844e4ce4f248605b4a9ae07268dea55d629265
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 2ffa0da..4636c43 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -364,6 +364,12 @@
LOG(INFO) << "Attempting to reset state from "
<< UpdateStatusToString(status_) << " to UpdateStatus::IDLE";
+ if (apex_handler_android_ != nullptr) {
+ LOG(INFO) << "Cleaning up reserved space for compressed APEX (if any)";
+ std::vector<ApexInfo> apex_infos_blank;
+ apex_handler_android_->AllocateSpace(apex_infos_blank);
+ }
+
switch (status_) {
case UpdateStatus::IDLE: {
if (!boot_control_->GetDynamicPartitionControl()->ResetUpdate(prefs_)) {