diff options
| author | Alex Deymo <deymo@google.com> | 2016-02-03 09:22:17 -0800 |
|---|---|---|
| committer | Alex Deymo <deymo@google.com> | 2016-02-03 20:52:47 -0800 |
| commit | 1f19dccb115cf608104b1cb0d192a53ae32f238f (patch) | |
| tree | 7f9ba9eab7aafb5d7727852a3ed369e086a3acb5 | |
| parent | 12542ace0f43c5afaf1e7112556b71aea8454c79 (diff) | |
Add ErrorCode::kUserCanceled.
To accomodate the posibility of canceling an ongoing update, this patch
adds a new ErrorCode signaling a user canceling the update.
This patch also removes the now useless unittests that checks if you
added a new error code since the compiler fails if you don't add the
error code to the method mentioned in the test.
Bug: None
TEST=FEATURES=test emerge-link update_engine
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng
Change-Id: I991dab1dd8b6c0bb0c24d51cca4e1b75440a86b4
| -rw-r--r-- | common/error_code.h | 5 | ||||
| -rw-r--r-- | common/utils.cc | 2 | ||||
| -rw-r--r-- | metrics.h | 1 | ||||
| -rw-r--r-- | metrics_utils.cc | 4 | ||||
| -rw-r--r-- | payload_state.cc | 2 | ||||
| -rw-r--r-- | payload_state_unittest.cc | 11 | ||||
| -rw-r--r-- | update_manager/chromeos_policy.cc | 3 |
7 files changed, 14 insertions, 14 deletions
diff --git a/common/error_code.h b/common/error_code.h index 2bbdcfa1..32155f27 100644 --- a/common/error_code.h +++ b/common/error_code.h @@ -71,6 +71,7 @@ enum class ErrorCode : int { kUnsupportedMinorPayloadVersion = 45, kOmahaRequestXMLHasEntityDecl = 46, kFilesystemVerifierError = 47, + kUserCanceled = 48, // VERY IMPORTANT! When adding new error codes: // @@ -122,8 +123,8 @@ enum class ErrorCode : int { // Mask that indicates bit positions that are used to indicate special flags // that are embedded in the error code to provide additional context about // the system in which the error was encountered. - kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag | - kTestOmahaUrlFlag) + kSpecialFlags = + (kDevModeFlag | kResumedFlag | kTestImageFlag | kTestOmahaUrlFlag) }; inline std::ostream& operator<<(std::ostream& os, ErrorCode val) { diff --git a/common/utils.cc b/common/utils.cc index 41a75f80..a09b4253 100644 --- a/common/utils.cc +++ b/common/utils.cc @@ -1110,6 +1110,8 @@ string CodeToString(ErrorCode code) { return "ErrorCode::kOmahaRequestXMLHasEntityDecl"; case ErrorCode::kFilesystemVerifierError: return "ErrorCode::kFilesystemVerifierError"; + case ErrorCode::kUserCanceled: + return "ErrorCode::kUserCanceled"; // Don't add a default case to let the compiler warn about newly added // error codes which should be added here. } @@ -149,6 +149,7 @@ enum class AttemptResult { kVerificationFailed, // Root or Kernel partition verification failed. kPostInstallFailed, // The postinstall step failed. kAbnormalTermination, // The attempt ended abnormally. + kUpdateCanceled, // Update canceled by the user. kNumConstants, diff --git a/metrics_utils.cc b/metrics_utils.cc index eb99c7d4..11260fc6 100644 --- a/metrics_utils.cc +++ b/metrics_utils.cc @@ -85,6 +85,9 @@ metrics::AttemptResult GetAttemptResult(ErrorCode code) { case ErrorCode::kPostinstallFirmwareRONotUpdatable: return metrics::AttemptResult::kPostInstallFailed; + case ErrorCode::kUserCanceled: + return metrics::AttemptResult::kUpdateCanceled; + // We should never get these errors in the update-attempt stage so // return internal error if this happens. case ErrorCode::kError: @@ -201,6 +204,7 @@ metrics::DownloadErrorCode GetDownloadErrorCode(ErrorCode code) { case ErrorCode::kUnsupportedMinorPayloadVersion: case ErrorCode::kOmahaRequestXMLHasEntityDecl: case ErrorCode::kFilesystemVerifierError: + case ErrorCode::kUserCanceled: break; // Special flags. These can't happen (we mask them out above) but diff --git a/payload_state.cc b/payload_state.cc index d7ccee5e..38a36f94 100644 --- a/payload_state.cc +++ b/payload_state.cc @@ -340,6 +340,7 @@ void PayloadState::UpdateFailed(ErrorCode error) { case ErrorCode::kUpdateCanceledByChannelChange: case ErrorCode::kOmahaRequestXMLHasEntityDecl: case ErrorCode::kFilesystemVerifierError: + case ErrorCode::kUserCanceled: LOG(INFO) << "Not incrementing URL index or failure count for this error"; break; @@ -608,6 +609,7 @@ void PayloadState::CollectAndReportAttemptMetrics(ErrorCode code) { case metrics::AttemptResult::kVerificationFailed: case metrics::AttemptResult::kPostInstallFailed: case metrics::AttemptResult::kAbnormalTermination: + case metrics::AttemptResult::kUpdateCanceled: case metrics::AttemptResult::kNumConstants: case metrics::AttemptResult::kUnset: break; diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc index a8067dca..44906374 100644 --- a/payload_state_unittest.cc +++ b/payload_state_unittest.cc @@ -101,17 +101,6 @@ static void SetupPayloadStateWith2Urls(string hash, class PayloadStateTest : public ::testing::Test { }; -TEST(PayloadStateTest, DidYouAddANewErrorCode) { - if (static_cast<int>(ErrorCode::kUmaReportedMax) != 48) { - LOG(ERROR) << "The following failure is intentional. If you added a new " - << "ErrorCode enum value, make sure to add it to the " - << "PayloadState::UpdateFailed method and then update this test " - << "to the new value of ErrorCode::kUmaReportedMax, which is " - << ErrorCode::kUmaReportedMax; - EXPECT_FALSE("Please see the log line above"); - } -} - TEST(PayloadStateTest, SetResponseWorksWithEmptyResponse) { OmahaResponse response; FakeSystemState fake_system_state; diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc index e3d99d0b..9abb21f5 100644 --- a/update_manager/chromeos_policy.cc +++ b/update_manager/chromeos_policy.cc @@ -129,6 +129,7 @@ bool HandleErrorCode(ErrorCode err_code, int* url_num_error_p) { case ErrorCode::kUpdateCanceledByChannelChange: case ErrorCode::kOmahaRequestXMLHasEntityDecl: case ErrorCode::kFilesystemVerifierError: + case ErrorCode::kUserCanceled: LOG(INFO) << "Not changing URL index or failure count due to error " << chromeos_update_engine::utils::CodeToString(err_code) << " (" << static_cast<int>(err_code) << ")"; @@ -137,7 +138,7 @@ bool HandleErrorCode(ErrorCode err_code, int* url_num_error_p) { case ErrorCode::kSuccess: // success code case ErrorCode::kUmaReportedMax: // not an error code case ErrorCode::kOmahaRequestHTTPResponseBase: // aggregated already - case ErrorCode::kDevModeFlag: // not an error code + case ErrorCode::kDevModeFlag: // not an error code case ErrorCode::kResumedFlag: // not an error code case ErrorCode::kTestImageFlag: // not an error code case ErrorCode::kTestOmahaUrlFlag: // not an error code |
