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