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