Add specific error codes to enable better error handling
When an applyPayload() call fails due to update already installed or
already processing, OEMs cannot distinguish between these cases, and are
forced to do string parsing. Report specific errors in these caess so
that OEMs can better handle these errors.
Test: th
Bug: 314046376
Change-Id: I3f98d4e93005154b9047dbb198e609606393f311
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index ea83d9a..0f4b2e4 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -242,18 +242,18 @@
const vector<string>& key_value_pair_headers,
Error* error) {
if (status_ == UpdateStatus::UPDATED_NEED_REBOOT) {
- return LogAndSetGenericError(
- error,
- __LINE__,
- __FILE__,
- "An update already applied, waiting for reboot");
+ return LogAndSetError(error,
+ __LINE__,
+ __FILE__,
+ "An update already applied, waiting for reboot",
+ ErrorCode::kUpdateAlreadyInstalled);
}
if (processor_->IsRunning()) {
- return LogAndSetGenericError(
- error,
- __LINE__,
- __FILE__,
- "Already processing an update, cancel it first.");
+ return LogAndSetError(error,
+ __LINE__,
+ __FILE__,
+ "Already processing an update, cancel it first.",
+ ErrorCode::kUpdateProcessing);
}
DCHECK_EQ(status_, UpdateStatus::IDLE);