| 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 |  | 
|  | 20 | namespace chromeos_update_engine { | 
|  | 21 |  | 
|  | 22 | // The name of the marker file used to trigger powerwash when post-install | 
|  | 23 | // completes successfully so that the device is powerwashed on next reboot. | 
|  | 24 | extern const char kPowerwashMarkerFile[]; | 
|  | 25 |  | 
|  | 26 | // The contents of the powerwash marker file. | 
|  | 27 | extern const char kPowerwashCommand[]; | 
|  | 28 |  | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 29 | // Directory for AU prefs that are preserved across powerwash. | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 30 | extern const char kPowerwashSafePrefsSubDirectory[]; | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 31 |  | 
|  | 32 | // The location where we store the AU preferences (state etc). | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 33 | extern const char kPrefsSubDirectory[]; | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 34 |  | 
| Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 35 | // Path to the stateful partition on the root filesystem. | 
|  | 36 | extern const char kStatefulPartition[]; | 
|  | 37 |  | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 38 | // Constants related to preferences. | 
| David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 39 | extern const char kPrefsAttemptInProgress[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 40 | extern const char kPrefsBackoffExpiryTime[]; | 
| Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 41 | extern const char kPrefsBootId[]; | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 42 | extern const char kPrefsCurrentBytesDownloaded[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 43 | extern const char kPrefsCurrentResponseSignature[]; | 
|  | 44 | extern const char kPrefsCurrentUrlFailureCount[]; | 
|  | 45 | extern const char kPrefsCurrentUrlIndex[]; | 
| David Zeuthen | 985b112 | 2013-10-09 12:13:15 -0700 | [diff] [blame] | 46 | extern const char kPrefsDailyMetricsLastReportedAt[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 47 | extern const char kPrefsDeltaUpdateFailures[]; | 
| Alex Deymo | 820cc70 | 2013-06-28 15:43:46 -0700 | [diff] [blame] | 48 | extern const char kPrefsFullPayloadAttemptNumber[]; | 
| David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 49 | extern const char kPrefsInstallDateDays[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 50 | extern const char kPrefsLastActivePingDay[]; | 
|  | 51 | extern const char kPrefsLastRollCallPingDay[]; | 
|  | 52 | extern const char kPrefsManifestMetadataSize[]; | 
| David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 53 | extern const char kPrefsMetricsAttemptLastReportingTime[]; | 
|  | 54 | extern const char kPrefsMetricsCheckLastReportingTime[]; | 
| Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 55 | extern const char kPrefsNumReboots[]; | 
| David Zeuthen | a573d6f | 2013-06-14 16:13:36 -0700 | [diff] [blame] | 56 | extern const char kPrefsNumResponsesSeen[]; | 
| Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 57 | extern const char kPrefsOmahaCohort[]; | 
|  | 58 | extern const char kPrefsOmahaCohortHint[]; | 
|  | 59 | extern const char kPrefsOmahaCohortName[]; | 
| David Zeuthen | 27a48bc | 2013-08-06 12:06:29 -0700 | [diff] [blame] | 60 | extern const char kPrefsP2PEnabled[]; | 
| David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 61 | extern const char kPrefsP2PFirstAttemptTimestamp[]; | 
|  | 62 | extern const char kPrefsP2PNumAttempts[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 63 | extern const char kPrefsPayloadAttemptNumber[]; | 
|  | 64 | extern const char kPrefsPreviousVersion[]; | 
|  | 65 | extern const char kPrefsResumedUpdateFailures[]; | 
| Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 66 | extern const char kPrefsRollbackVersion[]; | 
| Alex Deymo | 8561665 | 2015-10-15 18:48:31 -0700 | [diff] [blame] | 67 | extern const char kPrefsChannelOnSlotPrefix[]; | 
| David Zeuthen | e4c58bf | 2013-06-18 17:26:50 -0700 | [diff] [blame] | 68 | extern const char kPrefsSystemUpdatedMarker[]; | 
| Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 69 | extern const char kPrefsTargetVersionAttempt[]; | 
|  | 70 | extern const char kPrefsTargetVersionInstalledFrom[]; | 
|  | 71 | extern const char kPrefsTargetVersionUniqueId[]; | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 72 | extern const char kPrefsTotalBytesDownloaded[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 73 | extern const char kPrefsUpdateCheckCount[]; | 
|  | 74 | extern const char kPrefsUpdateCheckResponseHash[]; | 
| Alex Deymo | 906191f | 2015-10-12 12:22:44 -0700 | [diff] [blame] | 75 | extern const char kPrefsUpdateCompletedBootTime[]; | 
|  | 76 | extern const char kPrefsUpdateCompletedOnBootId[]; | 
| David Zeuthen | cc6f996 | 2013-04-18 11:57:24 -0700 | [diff] [blame] | 77 | extern const char kPrefsUpdateDurationUptime[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 78 | extern const char kPrefsUpdateFirstSeenAt[]; | 
| Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 79 | extern const char kPrefsUpdateOverCellularPermission[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 80 | extern const char kPrefsUpdateServerCertificate[]; | 
| David Zeuthen | 41996ad | 2013-09-24 15:43:24 -0700 | [diff] [blame] | 81 | extern const char kPrefsUpdateStateNextDataLength[]; | 
| David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 82 | extern const char kPrefsUpdateStateNextDataOffset[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 83 | extern const char kPrefsUpdateStateNextOperation[]; | 
|  | 84 | extern const char kPrefsUpdateStateSHA256Context[]; | 
|  | 85 | extern const char kPrefsUpdateStateSignatureBlob[]; | 
|  | 86 | extern const char kPrefsUpdateStateSignedSHA256Context[]; | 
| David Zeuthen | 9a017f2 | 2013-04-11 16:10:26 -0700 | [diff] [blame] | 87 | extern const char kPrefsUpdateTimestampStart[]; | 
| David Zeuthen | cc6f996 | 2013-04-18 11:57:24 -0700 | [diff] [blame] | 88 | extern const char kPrefsUrlSwitchCount[]; | 
|  | 89 | extern const char kPrefsWallClockWaitPeriod[]; | 
| Jay Srinivasan | d29695d | 2013-04-08 15:08:05 -0700 | [diff] [blame] | 90 |  | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 91 | // A download source is any combination of protocol and server (that's of | 
|  | 92 | // interest to us when looking at UMA metrics) using which we may download | 
|  | 93 | // the payload. | 
|  | 94 | typedef enum { | 
| Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 95 | kDownloadSourceHttpsServer,  // UMA Binary representation: 0001 | 
|  | 96 | kDownloadSourceHttpServer,   // UMA Binary representation: 0010 | 
|  | 97 | kDownloadSourceHttpPeer,     // UMA Binary representation: 0100 | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 98 |  | 
|  | 99 | // Note: Add new sources only above this line. | 
|  | 100 | kNumDownloadSources | 
|  | 101 | } DownloadSource; | 
|  | 102 |  | 
| Alex Deymo | 1c656c4 | 2013-06-28 11:02:14 -0700 | [diff] [blame] | 103 | // A payload can be a Full or Delta payload. In some cases, a Full payload is | 
|  | 104 | // used even when a Delta payload was available for the update, called here | 
|  | 105 | // ForcedFull. The PayloadType enum is only used to send UMA metrics about the | 
|  | 106 | // successfully applied payload. | 
|  | 107 | typedef enum { | 
|  | 108 | kPayloadTypeFull, | 
|  | 109 | kPayloadTypeDelta, | 
|  | 110 | kPayloadTypeForcedFull, | 
|  | 111 |  | 
|  | 112 | // Note: Add new payload types only above this line. | 
|  | 113 | kNumPayloadTypes | 
|  | 114 | } PayloadType; | 
|  | 115 |  | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 116 | // Maximum number of times we'll allow using p2p for the same update payload. | 
| David Zeuthen | dcba809 | 2013-08-06 12:16:35 -0700 | [diff] [blame] | 117 | const int kMaxP2PAttempts = 10; | 
|  | 118 |  | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 119 | // Maximum wallclock time we allow attempting to update using p2p for | 
| David Zeuthen | 472b205 | 2014-02-25 16:27:04 -0800 | [diff] [blame] | 120 | // the same update payload - five days. | 
|  | 121 | const int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60; | 
| David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 122 |  | 
|  | 123 | // The maximum amount of time to spend waiting for p2p-client(1) to | 
|  | 124 | // return while waiting in line to use the LAN - six hours. | 
|  | 125 | const int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60; | 
| David Zeuthen | dcba809 | 2013-08-06 12:16:35 -0700 | [diff] [blame] | 126 |  | 
| David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 127 | // The maximum number of payload files to keep in /var/cache/p2p. | 
|  | 128 | const int kMaxP2PFilesToKeep = 3; | 
|  | 129 |  | 
| David Zeuthen | 41f2cf5 | 2014-11-05 12:29:45 -0500 | [diff] [blame] | 130 | // The maximum number of days to keep a p2p file; | 
|  | 131 | const int kMaxP2PFileAgeDays = 5; | 
|  | 132 |  | 
| Jay Srinivasan | 19409b7 | 2013-04-12 19:23:36 -0700 | [diff] [blame] | 133 | // The default number of UMA buckets for metrics. | 
|  | 134 | const int kNumDefaultUmaBuckets = 50; | 
|  | 135 |  | 
|  | 136 | // General constants | 
|  | 137 | const int kNumBytesInOneMiB = 1024 * 1024; | 
|  | 138 |  | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 139 | // Number of redirects allowed when downloading. | 
|  | 140 | const int kDownloadMaxRedirects = 10; | 
|  | 141 |  | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 142 | // The minimum average speed that downloads must sustain... | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 143 | // | 
|  | 144 | // This is set low because some devices may have very poor | 
| Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 145 | // connectivity and we want to make as much forward progress as | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 146 | // 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] | 147 | // high bandwidth (same LAN) and we want to fail fast. | 
|  | 148 | const int kDownloadLowSpeedLimitBps = 1; | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 149 | const int kDownloadP2PLowSpeedLimitBps = 25 * 1000; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 150 |  | 
|  | 151 | // ... measured over this period. | 
|  | 152 | // | 
|  | 153 | // For non-official builds (e.g. typically built on a developer's | 
|  | 154 | // workstation and served via devserver) bump this since it takes time | 
|  | 155 | // for the workstation to generate the payload. For p2p, make this | 
|  | 156 | // relatively low since we want to fail fast. | 
|  | 157 | const int kDownloadLowSpeedTimeSeconds = 90; | 
|  | 158 | const int kDownloadDevModeLowSpeedTimeSeconds = 180; | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 159 | const int kDownloadP2PLowSpeedTimeSeconds = 60; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 160 |  | 
|  | 161 | // The maximum amount of HTTP server reconnect attempts. | 
|  | 162 | // | 
|  | 163 | // This is set high in order to maximize the attempt's chance of | 
|  | 164 | // succeeding. When using p2p, this is low in order to fail fast. | 
|  | 165 | const int kDownloadMaxRetryCount = 20; | 
|  | 166 | const int kDownloadMaxRetryCountOobeNotComplete = 3; | 
| David Zeuthen | a641be5 | 2013-09-12 10:59:57 -0700 | [diff] [blame] | 167 | const int kDownloadP2PMaxRetryCount = 5; | 
| David Zeuthen | 34135a9 | 2013-08-06 11:16:16 -0700 | [diff] [blame] | 168 |  | 
|  | 169 | // The connect timeout, in seconds. | 
|  | 170 | // | 
|  | 171 | // This is set high because some devices may have very poor | 
|  | 172 | // connectivity and we may be using HTTPS which involves complicated | 
|  | 173 | // multi-roundtrip setup. For p2p, this is set low because we can | 
|  | 174 | // the server is on the same LAN and we want to fail fast. | 
|  | 175 | const int kDownloadConnectTimeoutSeconds = 30; | 
|  | 176 | const int kDownloadP2PConnectTimeoutSeconds = 5; | 
|  | 177 |  | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 178 | }  // namespace chromeos_update_engine | 
|  | 179 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 180 | #endif  // UPDATE_ENGINE_COMMON_CONSTANTS_H_ |