New setting to mark postinstall as optional.
This setting allows to mark a postinstall script as optional. This
allows the postinstall program to fail when it is not strictly required
to run for the update to succeed.
Bug: 27178350
TEST=Added unittest. Sideloaded an update with an optional postinstall.
Change-Id: I41956d3308f3458b6bf94b835c9b5e470c84ca41
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 47b1947..9681e8c 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -304,7 +304,14 @@
// to get back to FW A.
error_code = ErrorCode::kPostinstallFirmwareRONotUpdatable;
}
- return CompletePostinstall(error_code);
+
+ // If postinstall script for this partition is optional we can ignore the
+ // result.
+ if (install_plan_.partitions[current_partition_].postinstall_optional) {
+ LOG(INFO) << "Ignoring postinstall failure since it is optional";
+ } else {
+ return CompletePostinstall(error_code);
+ }
}
accumulated_weight_ += partition_weight_[current_partition_];
current_partition_++;