| 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 | // | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 16 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_COMMON_CONSTANTS_H_ | 
|  | 18 | #define UPDATE_ENGINE_COMMON_CONSTANTS_H_ | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 19 |  | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 20 | #include <cstdint> | 
|  | 21 |  | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 22 | namespace chromeos_update_engine { | 
| Jae Hoon Kim | 38de3b1 | 2020-04-29 19:41:23 -0700 | [diff] [blame] | 23 | // The root path of all exclusion prefs. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 24 | static constexpr const auto& kExclusionPrefsSubDir = "exclusion"; | 
| Jae Hoon Kim | 38de3b1 | 2020-04-29 19:41:23 -0700 | [diff] [blame] | 25 |  | 
| Andrew | 065d78d | 2020-04-07 15:43:07 -0700 | [diff] [blame] | 26 | // The root path of all DLC metadata. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 27 | static constexpr const auto& kDlcPrefsSubDir = "dlc"; | 
| Andrew | e045aef | 2020-01-08 16:29:22 -0800 | [diff] [blame] | 28 |  | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 29 | // Directory for AU prefs that are preserved across powerwash. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 30 | static constexpr const auto& kPowerwashSafePrefsSubDirectory = | 
|  | 31 | "update_engine/prefs"; | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | // The location where we store the AU preferences (state etc). | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 34 | static constexpr const auto& kPrefsSubDirectory = "prefs"; | 
| Alex Deymo | 390efed | 2016-02-18 11:00:40 -0800 | [diff] [blame] | 35 |  | 
| Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 36 | // Path to the stateful partition on the root filesystem. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 37 | static constexpr const auto& kStatefulPartition = "/mnt/stateful_partition"; | 
|  | 38 |  | 
|  | 39 | // Path to the post install command, relative to the partition. | 
|  | 40 | static constexpr const auto& kPostinstallDefaultScript = "postinst"; | 
| Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 41 |  | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 42 | // Constants related to preferences. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 43 | // Constants defining keys for the persisted state of update engine. | 
|  | 44 | static constexpr const auto& kPrefsAttemptInProgress = "attempt-in-progress"; | 
|  | 45 | static constexpr const auto& kPrefsBackoffExpiryTime = "backoff-expiry-time"; | 
|  | 46 | static constexpr const auto& kPrefsBootId = "boot-id"; | 
|  | 47 | static constexpr const auto& kPrefsCurrentBytesDownloaded = | 
|  | 48 | "current-bytes-downloaded"; | 
|  | 49 | static constexpr const auto& kPrefsCurrentResponseSignature = | 
|  | 50 | "current-response-signature"; | 
|  | 51 | static constexpr const auto& kPrefsCurrentUrlFailureCount = | 
|  | 52 | "current-url-failure-count"; | 
|  | 53 | static constexpr const auto& kPrefsCurrentUrlIndex = "current-url-index"; | 
|  | 54 | static constexpr const auto& kPrefsDailyMetricsLastReportedAt = | 
|  | 55 | "daily-metrics-last-reported-at"; | 
|  | 56 | static constexpr const auto& kPrefsDeltaUpdateFailures = | 
|  | 57 | "delta-update-failures"; | 
|  | 58 | static constexpr const auto& kPrefsDynamicPartitionMetadataUpdated = | 
|  | 59 | "dynamic-partition-metadata-updated"; | 
|  | 60 | static constexpr const auto& kPrefsFullPayloadAttemptNumber = | 
|  | 61 | "full-payload-attempt-number"; | 
|  | 62 | static constexpr const auto& kPrefsInstallDateDays = "install-date-days"; | 
|  | 63 | static constexpr const auto& kPrefsLastActivePingDay = "last-active-ping-day"; | 
|  | 64 | static constexpr const auto& kPrefsLastRollCallPingDay = | 
|  | 65 | "last-roll-call-ping-day"; | 
|  | 66 | static constexpr const auto& kPrefsManifestMetadataSize = | 
|  | 67 | "manifest-metadata-size"; | 
|  | 68 | static constexpr const auto& kPrefsManifestSignatureSize = | 
|  | 69 | "manifest-signature-size"; | 
|  | 70 | static constexpr const auto& kPrefsMetricsAttemptLastReportingTime = | 
|  | 71 | "metrics-attempt-last-reporting-time"; | 
|  | 72 | static constexpr const auto& kPrefsMetricsCheckLastReportingTime = | 
|  | 73 | "metrics-check-last-reporting-time"; | 
|  | 74 | static constexpr const auto& kPrefsNoIgnoreBackoff = "no-ignore-backoff"; | 
|  | 75 | static constexpr const auto& kPrefsNumReboots = "num-reboots"; | 
|  | 76 | static constexpr const auto& kPrefsNumResponsesSeen = "num-responses-seen"; | 
|  | 77 | static constexpr const auto& kPrefsOmahaCohort = "omaha-cohort"; | 
|  | 78 | static constexpr const auto& kPrefsOmahaCohortHint = "omaha-cohort-hint"; | 
|  | 79 | static constexpr const auto& kPrefsOmahaCohortName = "omaha-cohort-name"; | 
|  | 80 | static constexpr const auto& kPrefsOmahaEolDate = "omaha-eol-date"; | 
|  | 81 | static constexpr const auto& kPrefsP2PEnabled = "p2p-enabled"; | 
|  | 82 | static constexpr const auto& kPrefsP2PFirstAttemptTimestamp = | 
|  | 83 | "p2p-first-attempt-timestamp"; | 
|  | 84 | static constexpr const auto& kPrefsP2PNumAttempts = "p2p-num-attempts"; | 
|  | 85 | static constexpr const auto& kPrefsPayloadAttemptNumber = | 
|  | 86 | "payload-attempt-number"; | 
|  | 87 | static constexpr const auto& kPrefsTestUpdateCheckIntervalTimeout = | 
|  | 88 | "test-update-check-interval-timeout"; | 
|  | 89 | // Keep |kPrefsPingActive| in sync with |kDlcMetadataFilePingActive| in | 
|  | 90 | // dlcservice. | 
|  | 91 | static constexpr const auto& kPrefsPingActive = "active"; | 
|  | 92 | static constexpr const auto& kPrefsPingLastActive = "date_last_active"; | 
|  | 93 | static constexpr const auto& kPrefsPingLastRollcall = "date_last_rollcall"; | 
|  | 94 | static constexpr const auto& kPrefsLastFp = "last-fp"; | 
|  | 95 | static constexpr const auto& kPrefsPostInstallSucceeded = | 
|  | 96 | "post-install-succeeded"; | 
|  | 97 | static constexpr const auto& kPrefsPreviousVersion = "previous-version"; | 
|  | 98 | static constexpr const auto& kPrefsResumedUpdateFailures = | 
|  | 99 | "resumed-update-failures"; | 
|  | 100 | static constexpr const auto& kPrefsRollbackHappened = "rollback-happened"; | 
|  | 101 | static constexpr const auto& kPrefsRollbackVersion = "rollback-version"; | 
|  | 102 | static constexpr const auto& kPrefsChannelOnSlotPrefix = "channel-on-slot-"; | 
|  | 103 | static constexpr const auto& kPrefsSystemUpdatedMarker = | 
|  | 104 | "system-updated-marker"; | 
|  | 105 | static constexpr const auto& kPrefsTargetVersionAttempt = | 
|  | 106 | "target-version-attempt"; | 
|  | 107 | static constexpr const auto& kPrefsTargetVersionInstalledFrom = | 
|  | 108 | "target-version-installed-from"; | 
|  | 109 | static constexpr const auto& kPrefsTargetVersionUniqueId = | 
|  | 110 | "target-version-unique-id"; | 
|  | 111 | static constexpr const auto& kPrefsTotalBytesDownloaded = | 
|  | 112 | "total-bytes-downloaded"; | 
|  | 113 | static constexpr const auto& kPrefsUpdateCheckCount = "update-check-count"; | 
|  | 114 | static constexpr const auto& kPrefsUpdateCheckResponseHash = | 
|  | 115 | "update-check-response-hash"; | 
|  | 116 | static constexpr const auto& kPrefsUpdateCompletedBootTime = | 
|  | 117 | "update-completed-boot-time"; | 
|  | 118 | static constexpr const auto& kPrefsUpdateCompletedOnBootId = | 
|  | 119 | "update-completed-on-boot-id"; | 
|  | 120 | static constexpr const auto& kPrefsUpdateDurationUptime = | 
|  | 121 | "update-duration-uptime"; | 
|  | 122 | static constexpr const auto& kPrefsUpdateFirstSeenAt = "update-first-seen-at"; | 
|  | 123 | static constexpr const auto& kPrefsUpdateOverCellularPermission = | 
|  | 124 | "update-over-cellular-permission"; | 
|  | 125 | static constexpr const auto& kPrefsUpdateOverCellularTargetVersion = | 
|  | 126 | "update-over-cellular-target-version"; | 
|  | 127 | static constexpr const auto& kPrefsUpdateOverCellularTargetSize = | 
|  | 128 | "update-over-cellular-target-size"; | 
|  | 129 | static constexpr const auto& kPrefsUpdateServerCertificate = | 
|  | 130 | "update-server-cert"; | 
|  | 131 | static constexpr const auto& kPrefsUpdateStateNextDataLength = | 
|  | 132 | "update-state-next-data-length"; | 
|  | 133 | static constexpr const auto& kPrefsUpdateStateNextDataOffset = | 
|  | 134 | "update-state-next-data-offset"; | 
|  | 135 | static constexpr const auto& kPrefsUpdateStateNextOperation = | 
|  | 136 | "update-state-next-operation"; | 
|  | 137 | static constexpr const auto& kPrefsUpdateStatePayloadIndex = | 
|  | 138 | "update-state-payload-index"; | 
|  | 139 | static constexpr const auto& kPrefsUpdateStateSHA256Context = | 
|  | 140 | "update-state-sha-256-context"; | 
|  | 141 | static constexpr const auto& kPrefsUpdateStateSignatureBlob = | 
|  | 142 | "update-state-signature-blob"; | 
|  | 143 | static constexpr const auto& kPrefsUpdateStateSignedSHA256Context = | 
|  | 144 | "update-state-signed-sha-256-context"; | 
|  | 145 | static constexpr const auto& kPrefsUpdateBootTimestampStart = | 
|  | 146 | "update-boot-timestamp-start"; | 
|  | 147 | static constexpr const auto& kPrefsUpdateTimestampStart = | 
|  | 148 | "update-timestamp-start"; | 
|  | 149 | static constexpr const auto& kPrefsUrlSwitchCount = "url-switch-count"; | 
|  | 150 | static constexpr const auto& kPrefsVerityWritten = "verity-written"; | 
|  | 151 | static constexpr const auto& kPrefsWallClockScatteringWaitPeriod = | 
|  | 152 | "wall-clock-wait-period"; | 
|  | 153 | static constexpr const auto& kPrefsWallClockStagingWaitPeriod = | 
|  | 154 | "wall-clock-staging-wait-period"; | 
|  | 155 | static constexpr const auto& kPrefsManifestBytes = "manifest-bytes"; | 
|  | 156 | static constexpr const auto& kPrefsPreviousSlot = "previous-slot"; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 157 |  | 
| Alex Deymo | 98e691c | 2016-02-04 21:05:45 -0800 | [diff] [blame] | 158 | // Keys used when storing and loading payload properties. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 159 | // These four fields are generated by scripts/brillo_update_payload. | 
|  | 160 | static constexpr const auto& kPayloadPropertyFileSize = "FILE_SIZE"; | 
|  | 161 | static constexpr const auto& kPayloadPropertyFileHash = "FILE_HASH"; | 
|  | 162 | static constexpr const auto& kPayloadPropertyMetadataSize = "METADATA_SIZE"; | 
|  | 163 | static constexpr const auto& kPayloadPropertyMetadataHash = "METADATA_HASH"; | 
|  | 164 | // The Authorization: HTTP header to be sent when downloading the payload. | 
|  | 165 | static constexpr const auto& kPayloadPropertyAuthorization = "AUTHORIZATION"; | 
|  | 166 | // The User-Agent HTTP header to be sent when downloading the payload. | 
|  | 167 | static constexpr const auto& kPayloadPropertyUserAgent = "USER_AGENT"; | 
|  | 168 | // Set "POWERWASH=1" to powerwash (factory data reset) the device after | 
|  | 169 | // applying the update. | 
|  | 170 | static constexpr const auto& kPayloadPropertyPowerwash = "POWERWASH"; | 
| Kelvin Zhang | 85a6d99 | 2023-10-23 10:40:58 -0700 | [diff] [blame] | 171 | static constexpr const auto& kPayloadPropertySplDowngrade = "SPL_DOWNGRADE"; | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 172 | // The network id to pass to android_setprocnetwork before downloading. | 
|  | 173 | // This can be used to zero-rate OTA traffic by sending it over the correct | 
|  | 174 | // network. | 
|  | 175 | static constexpr const auto& kPayloadPropertyNetworkId = "NETWORK_ID"; | 
| Kelvin Zhang | 98cb8f7 | 2022-08-03 12:42:02 -0700 | [diff] [blame] | 176 |  | 
|  | 177 | // Proxy URL to use for downloading OTA. This will be forwarded to libcurl | 
|  | 178 | static constexpr const auto& kPayloadPropertyNetworkProxy = "NETWORK_PROXY"; | 
|  | 179 |  | 
| Kelvin Zhang | 3cc4fa3 | 2022-09-27 16:15:10 -0700 | [diff] [blame] | 180 | // Set Virtual AB Compression's compression algorithm to "none", but still use | 
|  | 181 | // userspace snapshots and snapuserd for update installation. | 
| Kelvin Zhang | a7407b5 | 2023-03-13 15:05:14 -0700 | [diff] [blame] | 182 | static constexpr const auto& kPayloadVABCNone = "VABC_NONE"; | 
| Daniel Zheng | 9fc62b8 | 2023-03-24 22:57:20 +0000 | [diff] [blame] | 183 | // Enable/Disable VABC, falls back on plain VAB | 
|  | 184 | static constexpr const auto& kPayloadDisableVABC = "DISABLE_VABC"; | 
| Kelvin Zhang | 6bef490 | 2023-02-22 12:43:27 -0800 | [diff] [blame] | 185 | // Enable multi-threaded compression for VABC | 
|  | 186 | static constexpr const auto& kPayloadEnableThreading = "ENABLE_THREADING"; | 
|  | 187 | // Enable batched writes for VABC | 
|  | 188 | static constexpr const auto& kPayloadBatchedWrites = "BATCHED_WRITES"; | 
| Daniel Zheng | 730ae9b | 2022-08-25 22:37:22 +0000 | [diff] [blame] | 189 |  | 
| Kelvin Zhang | 3cc4fa3 | 2022-09-27 16:15:10 -0700 | [diff] [blame] | 190 | // Max retry count for download | 
|  | 191 | static constexpr const auto& kPayloadDownloadRetry = "DOWNLOAD_RETRY"; | 
|  | 192 |  | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 193 | // Set "SWITCH_SLOT_ON_REBOOT=0" to skip marking the updated partitions active. | 
|  | 194 | // The default is 1 (always switch slot if update succeeded). | 
|  | 195 | static constexpr const auto& kPayloadPropertySwitchSlotOnReboot = | 
|  | 196 | "SWITCH_SLOT_ON_REBOOT"; | 
|  | 197 | // Set "RUN_POST_INSTALL=0" to skip running optional post install. | 
|  | 198 | // The default is 1 (always run post install). | 
|  | 199 | static constexpr const auto& kPayloadPropertyRunPostInstall = | 
|  | 200 | "RUN_POST_INSTALL"; | 
| Alex Deymo | 98e691c | 2016-02-04 21:05:45 -0800 | [diff] [blame] | 201 |  | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 202 | static constexpr const auto& kOmahaUpdaterVersion = "0.1.0.0"; | 
| Amin Hassani | 7fca286 | 2019-03-28 16:09:22 -0700 | [diff] [blame] | 203 |  | 
| Jae Hoon Kim | 0ae8fe1 | 2019-06-26 14:32:50 -0700 | [diff] [blame] | 204 | // X-Goog-Update headers. | 
| Kelvin Zhang | 575b8f8 | 2021-05-13 11:14:44 -0400 | [diff] [blame] | 205 | // X-Goog-Update headers. | 
|  | 206 | static constexpr const auto& kXGoogleUpdateInteractivity = | 
|  | 207 | "X-Goog-Update-Interactivity"; | 
|  | 208 | static constexpr const auto& kXGoogleUpdateAppId = "X-Goog-Update-AppId"; | 
|  | 209 | static constexpr const auto& kXGoogleUpdateUpdater = "X-Goog-Update-Updater"; | 
|  | 210 | static constexpr const auto& kXGoogleUpdateSessionId = "X-Goog-SessionId"; | 
| Jae Hoon Kim | 0ae8fe1 | 2019-06-26 14:32:50 -0700 | [diff] [blame] | 211 |  | 
| Kelvin Zhang | c7a1d1f | 2022-07-29 13:36:29 -0700 | [diff] [blame] | 212 | // Proxy URL for direction connection | 
|  | 213 | static constexpr const auto& kNoProxy = "direct://"; | 
|  | 214 |  | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 215 | // A download source is any combination of protocol and server (that's of | 
|  | 216 | // interest to us when looking at UMA metrics) using which we may download | 
|  | 217 | // the payload. | 
|  | 218 | typedef enum { | 
| Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 219 | kDownloadSourceHttpsServer,  // UMA Binary representation: 0001 | 
|  | 220 | kDownloadSourceHttpServer,   // UMA Binary representation: 0010 | 
|  | 221 | kDownloadSourceHttpPeer,     // UMA Binary representation: 0100 | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 222 |  | 
|  | 223 | // Note: Add new sources only above this line. | 
|  | 224 | kNumDownloadSources | 
|  | 225 | } DownloadSource; | 
|  | 226 |  | 
| Alex Deymo | 1c656c4 | 2013-06-28 11:02:14 -0700 | [diff] [blame] | 227 | // A payload can be a Full or Delta payload. In some cases, a Full payload is | 
|  | 228 | // used even when a Delta payload was available for the update, called here | 
|  | 229 | // ForcedFull. The PayloadType enum is only used to send UMA metrics about the | 
|  | 230 | // successfully applied payload. | 
|  | 231 | typedef enum { | 
|  | 232 | kPayloadTypeFull, | 
|  | 233 | kPayloadTypeDelta, | 
|  | 234 | kPayloadTypeForcedFull, | 
|  | 235 |  | 
|  | 236 | // Note: Add new payload types only above this line. | 
|  | 237 | kNumPayloadTypes | 
|  | 238 | } PayloadType; | 
|  | 239 |  | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 240 | // Maximum number of times we'll allow using p2p for the same update payload. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 241 | constexpr int kMaxP2PAttempts = 10; | 
| David Zeuthen | dcba809 | 2013-08-06 12:16:35 -0700 | [diff] [blame] | 242 |  | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 243 | // Maximum wallclock time we allow attempting to update using p2p for | 
| David Zeuthen | 472b205 | 2014-02-25 16:27:04 -0800 | [diff] [blame] | 244 | // the same update payload - five days. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 245 | constexpr int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60; | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 246 |  | 
|  | 247 | // The maximum amount of time to spend waiting for p2p-client(1) to | 
|  | 248 | // return while waiting in line to use the LAN - six hours. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 249 | constexpr int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60; | 
| David Zeuthen | dcba809 | 2013-08-06 12:16:35 -0700 | [diff] [blame] | 250 |  | 
| David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 251 | // The maximum number of payload files to keep in /var/cache/p2p. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 252 | constexpr int kMaxP2PFilesToKeep = 3; | 
| David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 253 |  | 
| David Zeuthen | 41f2cf5 | 2014-11-05 12:29:45 -0500 | [diff] [blame] | 254 | // The maximum number of days to keep a p2p file; | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 255 | constexpr int kMaxP2PFileAgeDays = 5; | 
| David Zeuthen | 41f2cf5 | 2014-11-05 12:29:45 -0500 | [diff] [blame] | 256 |  | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 257 | // The default number of UMA buckets for metrics. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 258 | constexpr int kNumDefaultUmaBuckets = 50; | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 259 |  | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 260 | // General constexprants | 
|  | 261 | constexpr int kNumBytesInOneMiB = 1024 * 1024; | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 262 |  | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 263 | // Number of redirects allowed when downloading. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 264 | constexpr int kDownloadMaxRedirects = 10; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 265 |  | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 266 | // The minimum average speed that downloads must sustain... | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 267 | // | 
|  | 268 | // This is set low because some devices may have very poor | 
| Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 269 | // connectivity and we want to make as much forward progress as | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 270 | // possible. For p2p this is high (25 kB/second) since we can assume | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 271 | // high bandwidth (same LAN) and we want to fail fast. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 272 | constexpr int kDownloadLowSpeedLimitBps = 1; | 
|  | 273 | constexpr int kDownloadP2PLowSpeedLimitBps = 25 * 1000; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 274 |  | 
|  | 275 | // ... measured over this period. | 
|  | 276 | // | 
|  | 277 | // For non-official builds (e.g. typically built on a developer's | 
|  | 278 | // workstation and served via devserver) bump this since it takes time | 
| Aaron Wood | 2229059 | 2018-03-09 09:19:15 -0800 | [diff] [blame] | 279 | // for the workstation to generate the payload. For normal operation | 
|  | 280 | // and p2p, make this relatively low since we want to fail fast in | 
|  | 281 | // those cases. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 282 | constexpr int kDownloadLowSpeedTimeSeconds = 30; | 
|  | 283 | constexpr int kDownloadDevModeLowSpeedTimeSeconds = 180; | 
|  | 284 | constexpr int kDownloadP2PLowSpeedTimeSeconds = 60; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 285 |  | 
|  | 286 | // The maximum amount of HTTP server reconnect attempts. | 
|  | 287 | // | 
|  | 288 | // This is set high in order to maximize the attempt's chance of | 
|  | 289 | // succeeding. When using p2p, this is low in order to fail fast. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 290 | constexpr int kDownloadMaxRetryCount = 20; | 
|  | 291 | constexpr int kDownloadMaxRetryCountOobeNotComplete = 3; | 
|  | 292 | constexpr int kDownloadMaxRetryCountInteractive = 3; | 
|  | 293 | constexpr int kDownloadP2PMaxRetryCount = 5; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 294 |  | 
|  | 295 | // The connect timeout, in seconds. | 
|  | 296 | // | 
|  | 297 | // This is set high because some devices may have very poor | 
|  | 298 | // connectivity and we may be using HTTPS which involves complicated | 
|  | 299 | // multi-roundtrip setup. For p2p, this is set low because we can | 
|  | 300 | // the server is on the same LAN and we want to fail fast. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 301 | constexpr int kDownloadConnectTimeoutSeconds = 30; | 
|  | 302 | constexpr int kDownloadP2PConnectTimeoutSeconds = 5; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 303 |  | 
| xunchang | cda3c03 | 2019-03-26 15:41:14 -0700 | [diff] [blame] | 304 | // Size in bytes of SHA256 hash. | 
| Kelvin Zhang | ec205cf | 2020-09-28 13:23:40 -0400 | [diff] [blame] | 305 | constexpr int kSHA256Size = 32; | 
|  | 306 |  | 
|  | 307 | // A hardcoded label to mark end of all InstallOps | 
|  | 308 | // This number must be greater than number of install ops. | 
|  | 309 | // Number of install ops is bounded by number of blocks on any partition. | 
|  | 310 | // Currently, the block size is 4096. Using |kEndOfInstallLabel| of 2^48 will | 
|  | 311 | // allow partitions with 2^48 * 4096 = 2^60 bytes. That's 1024PB? Partitions on | 
|  | 312 | // android aren't getting that big any time soon. | 
|  | 313 | constexpr uint64_t kEndOfInstallLabel = (1ULL << 48); | 
| xunchang | cda3c03 | 2019-03-26 15:41:14 -0700 | [diff] [blame] | 314 |  | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 315 | }  // namespace chromeos_update_engine | 
|  | 316 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 317 | #endif  // UPDATE_ENGINE_COMMON_CONSTANTS_H_ |