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 // 16 17 #ifndef UPDATE_ENGINE_COMMON_CONSTANTS_H_ 18 #define UPDATE_ENGINE_COMMON_CONSTANTS_H_ 19 20 namespace chromeos_update_engine { 21 22 // The root path of all exclusion prefs. 23 extern const char kExclusionPrefsSubDir[]; 24 25 // The root path of all DLC metadata. 26 extern const char kDlcPrefsSubDir[]; 27 28 // Directory for AU prefs that are preserved across powerwash. 29 extern const char kPowerwashSafePrefsSubDirectory[]; 30 31 // The location where we store the AU preferences (state etc). 32 extern const char kPrefsSubDirectory[]; 33 34 // Path to the post install command, relative to the partition. 35 extern const char kPostinstallDefaultScript[]; 36 37 // Path to the stateful partition on the root filesystem. 38 extern const char kStatefulPartition[]; 39 40 // Constants related to preferences. 41 extern const char kPrefsAttemptInProgress[]; 42 extern const char kPrefsBackoffExpiryTime[]; 43 extern const char kPrefsBootId[]; 44 extern const char kPrefsCurrentBytesDownloaded[]; 45 extern const char kPrefsCurrentResponseSignature[]; 46 extern const char kPrefsCurrentUrlFailureCount[]; 47 extern const char kPrefsCurrentUrlIndex[]; 48 extern const char kPrefsDailyMetricsLastReportedAt[]; 49 extern const char kPrefsDeltaUpdateFailures[]; 50 extern const char kPrefsDynamicPartitionMetadataUpdated[]; 51 extern const char kPrefsFullPayloadAttemptNumber[]; 52 extern const char kPrefsInstallDateDays[]; 53 extern const char kPrefsLastActivePingDay[]; 54 extern const char kPrefsLastRollCallPingDay[]; 55 extern const char kPrefsManifestMetadataSize[]; 56 extern const char kPrefsManifestSignatureSize[]; 57 extern const char kPrefsMetricsAttemptLastReportingTime[]; 58 extern const char kPrefsMetricsCheckLastReportingTime[]; 59 extern const char kPrefsNoIgnoreBackoff[]; 60 extern const char kPrefsNumReboots[]; 61 extern const char kPrefsNumResponsesSeen[]; 62 extern const char kPrefsOmahaCohort[]; 63 extern const char kPrefsOmahaCohortHint[]; 64 extern const char kPrefsOmahaCohortName[]; 65 extern const char kPrefsOmahaEolDate[]; 66 extern const char kPrefsP2PEnabled[]; 67 extern const char kPrefsP2PFirstAttemptTimestamp[]; 68 extern const char kPrefsP2PNumAttempts[]; 69 extern const char kPrefsPayloadAttemptNumber[]; 70 extern const char kPrefsPingActive[]; 71 extern const char kPrefsPingLastActive[]; 72 extern const char kPrefsPingLastRollcall[]; 73 extern const char kPrefsPostInstallSucceeded[]; 74 extern const char kPrefsPreviousVersion[]; 75 extern const char kPrefsResumedUpdateFailures[]; 76 extern const char kPrefsRollbackHappened[]; 77 extern const char kPrefsRollbackVersion[]; 78 extern const char kPrefsChannelOnSlotPrefix[]; 79 extern const char kPrefsSystemUpdatedMarker[]; 80 extern const char kPrefsTargetVersionAttempt[]; 81 extern const char kPrefsTargetVersionInstalledFrom[]; 82 extern const char kPrefsTargetVersionUniqueId[]; 83 extern const char kPrefsTotalBytesDownloaded[]; 84 extern const char kPrefsUpdateCheckCount[]; 85 extern const char kPrefsUpdateCheckResponseHash[]; 86 extern const char kPrefsUpdateCompletedBootTime[]; 87 extern const char kPrefsUpdateCompletedOnBootId[]; 88 extern const char kPrefsUpdateDurationUptime[]; 89 extern const char kPrefsUpdateFirstSeenAt[]; 90 extern const char kPrefsUpdateOverCellularPermission[]; 91 extern const char kPrefsUpdateOverCellularTargetVersion[]; 92 extern const char kPrefsUpdateOverCellularTargetSize[]; 93 extern const char kPrefsUpdateServerCertificate[]; 94 extern const char kPrefsUpdateStateNextDataLength[]; 95 extern const char kPrefsUpdateStateNextDataOffset[]; 96 extern const char kPrefsUpdateStateNextOperation[]; 97 extern const char kPrefsUpdateStatePayloadIndex[]; 98 extern const char kPrefsUpdateStateSHA256Context[]; 99 extern const char kPrefsUpdateStateSignatureBlob[]; 100 extern const char kPrefsUpdateStateSignedSHA256Context[]; 101 extern const char kPrefsUpdateBootTimestampStart[]; 102 extern const char kPrefsUpdateTimestampStart[]; 103 extern const char kPrefsUrlSwitchCount[]; 104 extern const char kPrefsVerityWritten[]; 105 extern const char kPrefsWallClockScatteringWaitPeriod[]; 106 extern const char kPrefsWallClockStagingWaitPeriod[]; 107 extern const char kPrefsManifestBytes[]; 108 109 // Keys used when storing and loading payload properties. 110 extern const char kPayloadPropertyFileSize[]; 111 extern const char kPayloadPropertyFileHash[]; 112 extern const char kPayloadPropertyMetadataSize[]; 113 extern const char kPayloadPropertyMetadataHash[]; 114 extern const char kPayloadPropertyAuthorization[]; 115 extern const char kPayloadPropertyUserAgent[]; 116 extern const char kPayloadPropertyPowerwash[]; 117 extern const char kPayloadPropertyNetworkId[]; 118 extern const char kPayloadPropertySwitchSlotOnReboot[]; 119 extern const char kPayloadPropertyRunPostInstall[]; 120 121 extern const char kOmahaUpdaterVersion[]; 122 123 // X-Goog-Update headers. 124 extern const char kXGoogleUpdateInteractivity[]; 125 extern const char kXGoogleUpdateAppId[]; 126 extern const char kXGoogleUpdateUpdater[]; 127 extern const char kXGoogleUpdateSessionId[]; 128 129 // A download source is any combination of protocol and server (that's of 130 // interest to us when looking at UMA metrics) using which we may download 131 // the payload. 132 typedef enum { 133 kDownloadSourceHttpsServer, // UMA Binary representation: 0001 134 kDownloadSourceHttpServer, // UMA Binary representation: 0010 135 kDownloadSourceHttpPeer, // UMA Binary representation: 0100 136 137 // Note: Add new sources only above this line. 138 kNumDownloadSources 139 } DownloadSource; 140 141 // A payload can be a Full or Delta payload. In some cases, a Full payload is 142 // used even when a Delta payload was available for the update, called here 143 // ForcedFull. The PayloadType enum is only used to send UMA metrics about the 144 // successfully applied payload. 145 typedef enum { 146 kPayloadTypeFull, 147 kPayloadTypeDelta, 148 kPayloadTypeForcedFull, 149 150 // Note: Add new payload types only above this line. 151 kNumPayloadTypes 152 } PayloadType; 153 154 // Maximum number of times we'll allow using p2p for the same update payload. 155 const int kMaxP2PAttempts = 10; 156 157 // Maximum wallclock time we allow attempting to update using p2p for 158 // the same update payload - five days. 159 const int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60; 160 161 // The maximum amount of time to spend waiting for p2p-client(1) to 162 // return while waiting in line to use the LAN - six hours. 163 const int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60; 164 165 // The maximum number of payload files to keep in /var/cache/p2p. 166 const int kMaxP2PFilesToKeep = 3; 167 168 // The maximum number of days to keep a p2p file; 169 const int kMaxP2PFileAgeDays = 5; 170 171 // The default number of UMA buckets for metrics. 172 const int kNumDefaultUmaBuckets = 50; 173 174 // General constants 175 const int kNumBytesInOneMiB = 1024 * 1024; 176 177 // Number of redirects allowed when downloading. 178 const int kDownloadMaxRedirects = 10; 179 180 // The minimum average speed that downloads must sustain... 181 // 182 // This is set low because some devices may have very poor 183 // connectivity and we want to make as much forward progress as 184 // possible. For p2p this is high (25 kB/second) since we can assume 185 // high bandwidth (same LAN) and we want to fail fast. 186 const int kDownloadLowSpeedLimitBps = 1; 187 const int kDownloadP2PLowSpeedLimitBps = 25 * 1000; 188 189 // ... measured over this period. 190 // 191 // For non-official builds (e.g. typically built on a developer's 192 // workstation and served via devserver) bump this since it takes time 193 // for the workstation to generate the payload. For normal operation 194 // and p2p, make this relatively low since we want to fail fast in 195 // those cases. 196 const int kDownloadLowSpeedTimeSeconds = 30; 197 const int kDownloadDevModeLowSpeedTimeSeconds = 180; 198 const int kDownloadP2PLowSpeedTimeSeconds = 60; 199 200 // The maximum amount of HTTP server reconnect attempts. 201 // 202 // This is set high in order to maximize the attempt's chance of 203 // succeeding. When using p2p, this is low in order to fail fast. 204 const int kDownloadMaxRetryCount = 20; 205 const int kDownloadMaxRetryCountOobeNotComplete = 3; 206 const int kDownloadMaxRetryCountInteractive = 3; 207 const int kDownloadP2PMaxRetryCount = 5; 208 209 // The connect timeout, in seconds. 210 // 211 // This is set high because some devices may have very poor 212 // connectivity and we may be using HTTPS which involves complicated 213 // multi-roundtrip setup. For p2p, this is set low because we can 214 // the server is on the same LAN and we want to fail fast. 215 const int kDownloadConnectTimeoutSeconds = 30; 216 const int kDownloadP2PConnectTimeoutSeconds = 5; 217 218 // Size in bytes of SHA256 hash. 219 const int kSHA256Size = 32; 220 221 } // namespace chromeos_update_engine 222 223 #endif // UPDATE_ENGINE_COMMON_CONSTANTS_H_ 224