| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2013 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 16 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_COMMON_ERROR_CODE_H_ | 
|  | 18 | #define UPDATE_ENGINE_COMMON_ERROR_CODE_H_ | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 19 |  | 
| Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 20 | #include <ostream>  // NOLINT(readability/streams) | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 21 |  | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 22 | namespace chromeos_update_engine { | 
|  | 23 |  | 
|  | 24 | // Action exit codes. | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 25 | enum class ErrorCode : int { | 
|  | 26 | kSuccess = 0, | 
|  | 27 | kError = 1, | 
|  | 28 | kOmahaRequestError = 2, | 
|  | 29 | kOmahaResponseHandlerError = 3, | 
|  | 30 | kFilesystemCopierError = 4, | 
|  | 31 | kPostinstallRunnerError = 5, | 
|  | 32 | kPayloadMismatchedType = 6, | 
|  | 33 | kInstallDeviceOpenError = 7, | 
|  | 34 | kKernelDeviceOpenError = 8, | 
|  | 35 | kDownloadTransferError = 9, | 
|  | 36 | kPayloadHashMismatchError = 10, | 
|  | 37 | kPayloadSizeMismatchError = 11, | 
|  | 38 | kDownloadPayloadVerificationError = 12, | 
|  | 39 | kDownloadNewPartitionInfoError = 13, | 
|  | 40 | kDownloadWriteError = 14, | 
|  | 41 | kNewRootfsVerificationError = 15, | 
|  | 42 | kNewKernelVerificationError = 16, | 
|  | 43 | kSignedDeltaPayloadExpectedError = 17, | 
|  | 44 | kDownloadPayloadPubKeyVerificationError = 18, | 
|  | 45 | kPostinstallBootedFromFirmwareB = 19, | 
|  | 46 | kDownloadStateInitializationError = 20, | 
|  | 47 | kDownloadInvalidMetadataMagicString = 21, | 
|  | 48 | kDownloadSignatureMissingInManifest = 22, | 
|  | 49 | kDownloadManifestParseError = 23, | 
|  | 50 | kDownloadMetadataSignatureError = 24, | 
|  | 51 | kDownloadMetadataSignatureVerificationError = 25, | 
|  | 52 | kDownloadMetadataSignatureMismatch = 26, | 
|  | 53 | kDownloadOperationHashVerificationError = 27, | 
|  | 54 | kDownloadOperationExecutionError = 28, | 
|  | 55 | kDownloadOperationHashMismatch = 29, | 
|  | 56 | kOmahaRequestEmptyResponseError = 30, | 
|  | 57 | kOmahaRequestXMLParseError = 31, | 
|  | 58 | kDownloadInvalidMetadataSize = 32, | 
|  | 59 | kDownloadInvalidMetadataSignature = 33, | 
|  | 60 | kOmahaResponseInvalid = 34, | 
|  | 61 | kOmahaUpdateIgnoredPerPolicy = 35, | 
|  | 62 | kOmahaUpdateDeferredPerPolicy = 36, | 
|  | 63 | kOmahaErrorInHTTPResponse = 37, | 
|  | 64 | kDownloadOperationHashMissingError = 38, | 
|  | 65 | kDownloadMetadataSignatureMissingError = 39, | 
|  | 66 | kOmahaUpdateDeferredForBackoff = 40, | 
|  | 67 | kPostinstallPowerwashError = 41, | 
|  | 68 | kUpdateCanceledByChannelChange = 42, | 
|  | 69 | kPostinstallFirmwareRONotUpdatable = 43, | 
|  | 70 | kUnsupportedMajorPayloadVersion = 44, | 
|  | 71 | kUnsupportedMinorPayloadVersion = 45, | 
| David Zeuthen | f3e2801 | 2014-08-26 18:23:52 -0400 | [diff] [blame] | 72 | kOmahaRequestXMLHasEntityDecl = 46, | 
| Allie Wood | eb9e6d8 | 2015-04-17 13:55:30 -0700 | [diff] [blame] | 73 | kFilesystemVerifierError = 47, | 
| Alex Deymo | 1f19dcc | 2016-02-03 09:22:17 -0800 | [diff] [blame] | 74 | kUserCanceled = 48, | 
| Kevin Cernekee | 2494e28 | 2016-03-29 18:03:53 -0700 | [diff] [blame] | 75 | kNonCriticalUpdateInOOBE = 49, | 
| Weidong Guo | 421ff33 | 2017-04-17 10:08:38 -0700 | [diff] [blame] | 76 | kOmahaUpdateIgnoredOverCellular = 50, | 
| Sen Jiang | 8e768e9 | 2017-06-28 17:13:19 -0700 | [diff] [blame] | 77 | kPayloadTimestampError = 51, | 
| Sen Jiang | fe52282 | 2017-10-31 15:14:11 -0700 | [diff] [blame] | 78 | kUpdatedButNotActive = 52, | 
| Sen Jiang | 89e24c1 | 2018-03-22 18:05:44 -0700 | [diff] [blame] | 79 | kNoUpdate = 53, | 
| Marton Hunyady | 199152d | 2018-05-07 19:08:48 +0200 | [diff] [blame] | 80 | kRollbackNotPossible = 54, | 
| Amin Hassani | 80f4d4c | 2018-05-16 13:34:00 -0700 | [diff] [blame] | 81 | kFirstActiveOmahaPingSentPersistenceError = 55, | 
| Sen Jiang | 57f9180 | 2017-11-14 17:42:13 -0800 | [diff] [blame] | 82 | kVerityCalculationError = 56, | 
| Amin Hassani | d3d8421 | 2019-08-17 00:27:44 -0700 | [diff] [blame] | 83 | kInternalLibCurlError = 57, | 
|  | 84 | kUnresolvedHostError = 58, | 
|  | 85 | kUnresolvedHostRecovered = 59, | 
| Yifan Hong | 46e37d4 | 2019-12-13 12:01:42 -0800 | [diff] [blame] | 86 | kNotEnoughSpace = 60, | 
| Yifan Hong | 7727990 | 2019-12-17 16:38:21 -0800 | [diff] [blame] | 87 | kDeviceCorrupted = 61, | 
| Amin Hassani | e53b39b | 2020-09-16 11:19:28 -0700 | [diff] [blame] | 88 | kPackageExcludedFromUpdate = 62, | 
| Kelvin Zhang | 8b1e0dc | 2020-10-26 12:27:53 -0400 | [diff] [blame] | 89 | kPostInstallMountError = 63, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 90 |  | 
| Don Garrett | 4d03944 | 2013-10-28 18:40:06 -0700 | [diff] [blame] | 91 | // VERY IMPORTANT! When adding new error codes: | 
|  | 92 | // | 
| Marton Hunyady | 199152d | 2018-05-07 19:08:48 +0200 | [diff] [blame] | 93 | // 1) Update tools/metrics/histograms/enums.xml in Chrome. | 
| Don Garrett | 4d03944 | 2013-10-28 18:40:06 -0700 | [diff] [blame] | 94 | // | 
|  | 95 | // 2) Update the assorted switch statements in update_engine which won't | 
|  | 96 | //    build until this case is added. | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 97 |  | 
|  | 98 | // Any code above this is sent to both Omaha and UMA as-is, except | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 99 | // kOmahaErrorInHTTPResponse (see error code 2000 for more details). | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 100 | // Codes/flags below this line is sent only to Omaha and not to UMA. | 
|  | 101 |  | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 102 | // kUmaReportedMax is not an error code per se, it's just the count | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 103 | // of the number of enums above.  Add any new errors above this line if you | 
|  | 104 | // want them to show up on UMA. Stuff below this line will not be sent to UMA | 
|  | 105 | // but is used for other errors that are sent to Omaha. We don't assign any | 
|  | 106 | // particular value for this enum so that it's just one more than the last | 
|  | 107 | // one above and thus always represents the correct count of UMA metrics | 
|  | 108 | // buckets, even when new enums are added above this line in future. See | 
| Alex Deymo | af9a863 | 2015-09-23 18:51:48 -0700 | [diff] [blame] | 109 | // metrics::ReportUpdateAttemptMetrics() on how this enum is used. | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 110 | kUmaReportedMax, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 111 |  | 
|  | 112 | // use the 2xxx range to encode HTTP errors. These errors are available in | 
|  | 113 | // Dremel with the individual granularity. But for UMA purposes, all these | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 114 | // errors are aggregated into one: kOmahaErrorInHTTPResponse. | 
|  | 115 | kOmahaRequestHTTPResponseBase = 2000,  // + HTTP response code | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 116 |  | 
|  | 117 | // TODO(jaysri): Move out all the bit masks into separate constants | 
|  | 118 | // outside the enum as part of fixing bug 34369. | 
|  | 119 | // Bit flags. Remember to update the mask below for new bits. | 
|  | 120 |  | 
|  | 121 | // Set if boot mode not normal. | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 122 | // TODO(garnold) This is very debatable value to use, knowing that the | 
|  | 123 | // underlying type is a signed int (often, 32-bit). However, at this point | 
|  | 124 | // there are parts of the ecosystem that expect this to be a negative value, | 
|  | 125 | // so we preserve this semantics. This should be reconsidered if/when we | 
|  | 126 | // modify the implementation of ErrorCode into a properly encapsulated class. | 
|  | 127 | kDevModeFlag = 1 << 31, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 128 |  | 
| Sen Jiang | 771f648 | 2018-04-04 17:59:10 -0700 | [diff] [blame] | 129 | // Set if resuming an interrupted update. | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 130 | kResumedFlag = 1 << 30, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 131 |  | 
|  | 132 | // Set if using a dev/test image as opposed to an MP-signed image. | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 133 | kTestImageFlag = 1 << 29, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 134 |  | 
|  | 135 | // Set if using devserver or Omaha sandbox (using crosh autest). | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 136 | kTestOmahaUrlFlag = 1 << 28, | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 137 |  | 
|  | 138 | // Mask that indicates bit positions that are used to indicate special flags | 
|  | 139 | // that are embedded in the error code to provide additional context about | 
|  | 140 | // the system in which the error was encountered. | 
| Alex Deymo | 1f19dcc | 2016-02-03 09:22:17 -0800 | [diff] [blame] | 141 | kSpecialFlags = | 
|  | 142 | (kDevModeFlag | kResumedFlag | kTestImageFlag | kTestOmahaUrlFlag) | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 143 | }; | 
|  | 144 |  | 
| Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 145 | inline std::ostream& operator<<(std::ostream& os, ErrorCode val) { | 
|  | 146 | return os << static_cast<int>(val); | 
|  | 147 | } | 
|  | 148 |  | 
| David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 149 | }  // namespace chromeos_update_engine | 
|  | 150 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 151 | #endif  // UPDATE_ENGINE_COMMON_ERROR_CODE_H_ |