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