constants.h revision 87792ea818a63f2d246bbba2b7429b85ee8d669f
1aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 2aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Copyright (C) 2013 The Android Open Source Project 3aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 4aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Licensed under the Apache License, Version 2.0 (the "License"); 5aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// you may not use this file except in compliance with the License. 6aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// You may obtain a copy of the License at 7aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 8aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// http://www.apache.org/licenses/LICENSE-2.0 9aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 10aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// Unless required by applicable law or agreed to in writing, software 11aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// distributed under the License is distributed on an "AS IS" BASIS, 12aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// See the License for the specific language governing permissions and 14aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// limitations under the License. 15aea4c1cea20dda7ae7e85fc8924a2d784f70d806Alex Deymo// 161c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasan 1739910dcd1d68987ccee7c3031dc269233a8490bbAlex Deymo#ifndef UPDATE_ENGINE_COMMON_CONSTANTS_H_ 1839910dcd1d68987ccee7c3031dc269233a8490bbAlex Deymo#define UPDATE_ENGINE_COMMON_CONSTANTS_H_ 191c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasan 201c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasannamespace chromeos_update_engine { 211c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasan 22aa18e1641879f2df5993c2b02eb6f50d4443a649Chris Sosa// Directory for AU prefs that are preserved across powerwash. 23dd132f39cced9028c01e98895a4f6c5fb9553de1Alex Deymoextern const char kPowerwashSafePrefsSubDirectory[]; 24aa18e1641879f2df5993c2b02eb6f50d4443a649Chris Sosa 25aa18e1641879f2df5993c2b02eb6f50d4443a649Chris Sosa// The location where we store the AU preferences (state etc). 26dd132f39cced9028c01e98895a4f6c5fb9553de1Alex Deymoextern const char kPrefsSubDirectory[]; 27aa18e1641879f2df5993c2b02eb6f50d4443a649Chris Sosa 28390efedcb7e17587da765b6d682077cb7fa46ee1Alex Deymo// Path to the post install command, relative to the partition. 29390efedcb7e17587da765b6d682077cb7fa46ee1Alex Deymoextern const char kPostinstallDefaultScript[]; 30390efedcb7e17587da765b6d682077cb7fa46ee1Alex Deymo 31be45bef9e283188b00e7def8967f81843669a7f1Chris Sosa// Path to the stateful partition on the root filesystem. 32be45bef9e283188b00e7def8967f81843669a7f1Chris Sosaextern const char kStatefulPartition[]; 33be45bef9e283188b00e7def8967f81843669a7f1Chris Sosa 34d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasan// Constants related to preferences. 354e1d1495c034c8a81c989622481b6cdf94a50c3cDavid Zeuthenextern const char kPrefsAttemptInProgress[]; 36d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsBackoffExpiryTime[]; 37dd132f39cced9028c01e98895a4f6c5fb9553de1Alex Deymoextern const char kPrefsBootId[]; 3819409b74019d787100b768306e75ab3e5882898dJay Srinivasanextern const char kPrefsCurrentBytesDownloaded[]; 39d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsCurrentResponseSignature[]; 40d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsCurrentUrlFailureCount[]; 41d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsCurrentUrlIndex[]; 42985b112a749ccbe025ea4aa0245b13f92c28a057David Zeuthenextern const char kPrefsDailyMetricsLastReportedAt[]; 43d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsDeltaUpdateFailures[]; 44820cc706c5ef60a3be96f5487f616bfed2b1d207Alex Deymoextern const char kPrefsFullPayloadAttemptNumber[]; 45639aa36fc7e27ba400402cd7a32b091f555783a6David Zeuthenextern const char kPrefsInstallDateDays[]; 46d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsLastActivePingDay[]; 47d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsLastRollCallPingDay[]; 48d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsManifestMetadataSize[]; 49f25eb491ff60f21659a7e2b230ee1c83957034c7Alex Deymoextern const char kPrefsManifestSignatureSize[]; 5033bae491eded4ef4f1eb4f4ef0f01ef0e5463f3aDavid Zeuthenextern const char kPrefsMetricsAttemptLastReportingTime[]; 5133bae491eded4ef4f1eb4f4ef0f01ef0e5463f3aDavid Zeuthenextern const char kPrefsMetricsCheckLastReportingTime[]; 52be45bef9e283188b00e7def8967f81843669a7f1Chris Sosaextern const char kPrefsNumReboots[]; 53a573d6fd046dc203b96bff6df8e57b35319906fdDavid Zeuthenextern const char kPrefsNumResponsesSeen[]; 548e18f931f634d7c3b3a5fcbfc057e79fa9d6fb80Alex Deymoextern const char kPrefsOmahaCohort[]; 558e18f931f634d7c3b3a5fcbfc057e79fa9d6fb80Alex Deymoextern const char kPrefsOmahaCohortHint[]; 568e18f931f634d7c3b3a5fcbfc057e79fa9d6fb80Alex Deymoextern const char kPrefsOmahaCohortName[]; 57b3fa53bf760bd0a6fd1ef9df28cb425586d733f6Alex Deymoextern const char kPrefsOmahaEolStatus[]; 5827a48bc3f2531166370c214f7a21e17fb1fc7af1David Zeuthenextern const char kPrefsP2PEnabled[]; 59639aa36fc7e27ba400402cd7a32b091f555783a6David Zeuthenextern const char kPrefsP2PFirstAttemptTimestamp[]; 60639aa36fc7e27ba400402cd7a32b091f555783a6David Zeuthenextern const char kPrefsP2PNumAttempts[]; 61d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsPayloadAttemptNumber[]; 62d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsPreviousVersion[]; 63d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsResumedUpdateFailures[]; 64aa18e1641879f2df5993c2b02eb6f50d4443a649Chris Sosaextern const char kPrefsRollbackVersion[]; 65856166594771c61973856f563e622ccb7dd48aa1Alex Deymoextern const char kPrefsChannelOnSlotPrefix[]; 66e4c58bf01b6ccc915c6b261007dbb75241ed69b8David Zeuthenextern const char kPrefsSystemUpdatedMarker[]; 674243291a6655972fe89d4747a0089834c9e47c20Alex Deymoextern const char kPrefsTargetVersionAttempt[]; 684243291a6655972fe89d4747a0089834c9e47c20Alex Deymoextern const char kPrefsTargetVersionInstalledFrom[]; 694243291a6655972fe89d4747a0089834c9e47c20Alex Deymoextern const char kPrefsTargetVersionUniqueId[]; 7019409b74019d787100b768306e75ab3e5882898dJay Srinivasanextern const char kPrefsTotalBytesDownloaded[]; 71d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateCheckCount[]; 72d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateCheckResponseHash[]; 73906191f88cb2448691e54f7a6a3b464854053154Alex Deymoextern const char kPrefsUpdateCompletedBootTime[]; 74906191f88cb2448691e54f7a6a3b464854053154Alex Deymoextern const char kPrefsUpdateCompletedOnBootId[]; 75cc6f99600b3354cfe3a0d212241e1ee1dc3421b6David Zeuthenextern const char kPrefsUpdateDurationUptime[]; 76d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateFirstSeenAt[]; 77f4867c4dab4d1ca566f1aa3f585bd16d87b911ddAlex Deymoextern const char kPrefsUpdateOverCellularPermission[]; 78d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateServerCertificate[]; 7941996ad21f29f825dfa7d61f12a3fad7319bf36dDavid Zeuthenextern const char kPrefsUpdateStateNextDataLength[]; 80639aa36fc7e27ba400402cd7a32b091f555783a6David Zeuthenextern const char kPrefsUpdateStateNextDataOffset[]; 81d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateStateNextOperation[]; 82d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateStateSHA256Context[]; 83d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateStateSignatureBlob[]; 84d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasanextern const char kPrefsUpdateStateSignedSHA256Context[]; 859a017f2c5ae41c04a7c7c15b5dbd08faadae7606David Zeuthenextern const char kPrefsUpdateTimestampStart[]; 86cc6f99600b3354cfe3a0d212241e1ee1dc3421b6David Zeuthenextern const char kPrefsUrlSwitchCount[]; 87cc6f99600b3354cfe3a0d212241e1ee1dc3421b6David Zeuthenextern const char kPrefsWallClockWaitPeriod[]; 88d29695df35b7192faef4009d42a62c37bdd90a8fJay Srinivasan 8998e691cc6debda3ef671acba001bebd45da36377Alex Deymo// Keys used when storing and loading payload properties. 9098e691cc6debda3ef671acba001bebd45da36377Alex Deymoextern const char kPayloadPropertyFileSize[]; 9198e691cc6debda3ef671acba001bebd45da36377Alex Deymoextern const char kPayloadPropertyFileHash[]; 9298e691cc6debda3ef671acba001bebd45da36377Alex Deymoextern const char kPayloadPropertyMetadataSize[]; 9398e691cc6debda3ef671acba001bebd45da36377Alex Deymoextern const char kPayloadPropertyMetadataHash[]; 94fdd6dec9c4be2fbd667cf874c4cc6f4ffecaeef9Alex Deymoextern const char kPayloadPropertyAuthorization[]; 95fdd6dec9c4be2fbd667cf874c4cc6f4ffecaeef9Alex Deymoextern const char kPayloadPropertyUserAgent[]; 96fb905d9b8d49f8fe41297c7aba2dd0942f1be311Alex Deymoextern const char kPayloadPropertyPowerwash[]; 9787792ea818a63f2d246bbba2b7429b85ee8d669fAlex Deymoextern const char kPayloadPropertyNetworkId[]; 9898e691cc6debda3ef671acba001bebd45da36377Alex Deymo 9919409b74019d787100b768306e75ab3e5882898dJay Srinivasan// A download source is any combination of protocol and server (that's of 10019409b74019d787100b768306e75ab3e5882898dJay Srinivasan// interest to us when looking at UMA metrics) using which we may download 10119409b74019d787100b768306e75ab3e5882898dJay Srinivasan// the payload. 10219409b74019d787100b768306e75ab3e5882898dJay Srinivasantypedef enum { 103d2779df63aaad8b65fc5d4badee7dbc9bed7f2b6Alex Vakulenko kDownloadSourceHttpsServer, // UMA Binary representation: 0001 104d2779df63aaad8b65fc5d4badee7dbc9bed7f2b6Alex Vakulenko kDownloadSourceHttpServer, // UMA Binary representation: 0010 105d2779df63aaad8b65fc5d4badee7dbc9bed7f2b6Alex Vakulenko kDownloadSourceHttpPeer, // UMA Binary representation: 0100 10619409b74019d787100b768306e75ab3e5882898dJay Srinivasan 10719409b74019d787100b768306e75ab3e5882898dJay Srinivasan // Note: Add new sources only above this line. 10819409b74019d787100b768306e75ab3e5882898dJay Srinivasan kNumDownloadSources 10919409b74019d787100b768306e75ab3e5882898dJay Srinivasan} DownloadSource; 11019409b74019d787100b768306e75ab3e5882898dJay Srinivasan 1111c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo// A payload can be a Full or Delta payload. In some cases, a Full payload is 1121c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo// used even when a Delta payload was available for the update, called here 1131c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo// ForcedFull. The PayloadType enum is only used to send UMA metrics about the 1141c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo// successfully applied payload. 1151c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymotypedef enum { 1161c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo kPayloadTypeFull, 1171c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo kPayloadTypeDelta, 1181c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo kPayloadTypeForcedFull, 1191c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo 1201c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo // Note: Add new payload types only above this line. 1211c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo kNumPayloadTypes 1221c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo} PayloadType; 1231c656c48886cf5054b526ed7e95b05903d7644dbAlex Deymo 1248f191b22a1a1ab2b803d65ee488729206e648695David Zeuthen// Maximum number of times we'll allow using p2p for the same update payload. 125dcba8098a905018e6fe2e8e4e3b121a255f0d99eDavid Zeuthenconst int kMaxP2PAttempts = 10; 126dcba8098a905018e6fe2e8e4e3b121a255f0d99eDavid Zeuthen 1278f191b22a1a1ab2b803d65ee488729206e648695David Zeuthen// Maximum wallclock time we allow attempting to update using p2p for 128472b205c8afdb22ba22ba12ece667263b0e4fb99David Zeuthen// the same update payload - five days. 129472b205c8afdb22ba22ba12ece667263b0e4fb99David Zeuthenconst int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60; 1308f191b22a1a1ab2b803d65ee488729206e648695David Zeuthen 1318f191b22a1a1ab2b803d65ee488729206e648695David Zeuthen// The maximum amount of time to spend waiting for p2p-client(1) to 1328f191b22a1a1ab2b803d65ee488729206e648695David Zeuthen// return while waiting in line to use the LAN - six hours. 1338f191b22a1a1ab2b803d65ee488729206e648695David Zeuthenconst int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60; 134dcba8098a905018e6fe2e8e4e3b121a255f0d99eDavid Zeuthen 135526cb58ddecbbc1ba5d2e3faf068d26d0661d464David Zeuthen// The maximum number of payload files to keep in /var/cache/p2p. 136526cb58ddecbbc1ba5d2e3faf068d26d0661d464David Zeuthenconst int kMaxP2PFilesToKeep = 3; 137526cb58ddecbbc1ba5d2e3faf068d26d0661d464David Zeuthen 13841f2cf52137dd94ef9115e27ec8729a126edb0ffDavid Zeuthen// The maximum number of days to keep a p2p file; 13941f2cf52137dd94ef9115e27ec8729a126edb0ffDavid Zeuthenconst int kMaxP2PFileAgeDays = 5; 14041f2cf52137dd94ef9115e27ec8729a126edb0ffDavid Zeuthen 14119409b74019d787100b768306e75ab3e5882898dJay Srinivasan// The default number of UMA buckets for metrics. 14219409b74019d787100b768306e75ab3e5882898dJay Srinivasanconst int kNumDefaultUmaBuckets = 50; 14319409b74019d787100b768306e75ab3e5882898dJay Srinivasan 14419409b74019d787100b768306e75ab3e5882898dJay Srinivasan// General constants 14519409b74019d787100b768306e75ab3e5882898dJay Srinivasanconst int kNumBytesInOneMiB = 1024 * 1024; 14619409b74019d787100b768306e75ab3e5882898dJay Srinivasan 14734135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// Number of redirects allowed when downloading. 14834135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadMaxRedirects = 10; 14934135a9f24c72137aa85378b57e7698162c687f2David Zeuthen 150a641be56452b67449e03444f1a08007f74638a70David Zeuthen// The minimum average speed that downloads must sustain... 15134135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// 15234135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// This is set low because some devices may have very poor 153072359ca138504065e1e0c1189eb38c09576d324Alex Vakulenko// connectivity and we want to make as much forward progress as 154a641be56452b67449e03444f1a08007f74638a70David Zeuthen// possible. For p2p this is high (25 kB/second) since we can assume 15534135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// high bandwidth (same LAN) and we want to fail fast. 15634135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadLowSpeedLimitBps = 1; 157a641be56452b67449e03444f1a08007f74638a70David Zeuthenconst int kDownloadP2PLowSpeedLimitBps = 25 * 1000; 15834135a9f24c72137aa85378b57e7698162c687f2David Zeuthen 15934135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// ... measured over this period. 16034135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// 16134135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// For non-official builds (e.g. typically built on a developer's 16234135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// workstation and served via devserver) bump this since it takes time 16334135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// for the workstation to generate the payload. For p2p, make this 16434135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// relatively low since we want to fail fast. 16534135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadLowSpeedTimeSeconds = 90; 16634135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadDevModeLowSpeedTimeSeconds = 180; 167a641be56452b67449e03444f1a08007f74638a70David Zeuthenconst int kDownloadP2PLowSpeedTimeSeconds = 60; 16834135a9f24c72137aa85378b57e7698162c687f2David Zeuthen 16934135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// The maximum amount of HTTP server reconnect attempts. 17034135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// 17134135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// This is set high in order to maximize the attempt's chance of 17234135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// succeeding. When using p2p, this is low in order to fail fast. 17334135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadMaxRetryCount = 20; 17434135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadMaxRetryCountOobeNotComplete = 3; 175a641be56452b67449e03444f1a08007f74638a70David Zeuthenconst int kDownloadP2PMaxRetryCount = 5; 17634135a9f24c72137aa85378b57e7698162c687f2David Zeuthen 17734135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// The connect timeout, in seconds. 17834135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// 17934135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// This is set high because some devices may have very poor 18034135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// connectivity and we may be using HTTPS which involves complicated 18134135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// multi-roundtrip setup. For p2p, this is set low because we can 18234135a9f24c72137aa85378b57e7698162c687f2David Zeuthen// the server is on the same LAN and we want to fail fast. 18334135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadConnectTimeoutSeconds = 30; 18434135a9f24c72137aa85378b57e7698162c687f2David Zeuthenconst int kDownloadP2PConnectTimeoutSeconds = 5; 18534135a9f24c72137aa85378b57e7698162c687f2David Zeuthen 1861c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasan} // namespace chromeos_update_engine 1871c0fe79c7ef2b43946d756b54c8505d2bf48b93bJay Srinivasan 18839910dcd1d68987ccee7c3031dc269233a8490bbAlex Deymo#endif // UPDATE_ENGINE_COMMON_CONSTANTS_H_ 189