blob: ab66921e340837619ab3641883ce4e99ff47028e [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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 Srinivasan1c0fe792013-03-28 16:45:25 -070016
Alex Deymo39910dc2015-11-09 17:04:30 -080017#ifndef UPDATE_ENGINE_COMMON_CONSTANTS_H_
18#define UPDATE_ENGINE_COMMON_CONSTANTS_H_
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070019
20namespace chromeos_update_engine {
21
Chris Sosaaa18e162013-06-20 13:20:30 -070022// Directory for AU prefs that are preserved across powerwash.
Alex Deymodd132f32015-09-14 19:12:07 -070023extern const char kPowerwashSafePrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070024
25// The location where we store the AU preferences (state etc).
Alex Deymodd132f32015-09-14 19:12:07 -070026extern const char kPrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070027
Alex Deymo390efed2016-02-18 11:00:40 -080028// Path to the post install command, relative to the partition.
29extern const char kPostinstallDefaultScript[];
30
Chris Sosabe45bef2013-04-09 18:25:12 -070031// Path to the stateful partition on the root filesystem.
32extern const char kStatefulPartition[];
33
Jay Srinivasand29695d2013-04-08 15:08:05 -070034// Constants related to preferences.
David Zeuthen4e1d1492014-04-25 13:12:27 -070035extern const char kPrefsAttemptInProgress[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070036extern const char kPrefsBackoffExpiryTime[];
Alex Deymodd132f32015-09-14 19:12:07 -070037extern const char kPrefsBootId[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070038extern const char kPrefsCurrentBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070039extern const char kPrefsCurrentResponseSignature[];
40extern const char kPrefsCurrentUrlFailureCount[];
41extern const char kPrefsCurrentUrlIndex[];
David Zeuthen985b1122013-10-09 12:13:15 -070042extern const char kPrefsDailyMetricsLastReportedAt[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070043extern const char kPrefsDeltaUpdateFailures[];
Alex Deymo820cc702013-06-28 15:43:46 -070044extern const char kPrefsFullPayloadAttemptNumber[];
David Zeuthen639aa362014-02-03 16:23:44 -080045extern const char kPrefsInstallDateDays[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070046extern const char kPrefsLastActivePingDay[];
47extern const char kPrefsLastRollCallPingDay[];
48extern const char kPrefsManifestMetadataSize[];
Alex Deymof25eb492016-02-26 00:20:08 -080049extern const char kPrefsManifestSignatureSize[];
David Zeuthen33bae492014-02-25 16:16:18 -080050extern const char kPrefsMetricsAttemptLastReportingTime[];
51extern const char kPrefsMetricsCheckLastReportingTime[];
Chris Sosabe45bef2013-04-09 18:25:12 -070052extern const char kPrefsNumReboots[];
David Zeuthena573d6f2013-06-14 16:13:36 -070053extern const char kPrefsNumResponsesSeen[];
Alex Deymo8e18f932015-03-27 16:16:59 -070054extern const char kPrefsOmahaCohort[];
55extern const char kPrefsOmahaCohortHint[];
56extern const char kPrefsOmahaCohortName[];
Alex Deymob3fa53b2016-04-18 19:57:58 -070057extern const char kPrefsOmahaEolStatus[];
David Zeuthen27a48bc2013-08-06 12:06:29 -070058extern const char kPrefsP2PEnabled[];
David Zeuthen639aa362014-02-03 16:23:44 -080059extern const char kPrefsP2PFirstAttemptTimestamp[];
60extern const char kPrefsP2PNumAttempts[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070061extern const char kPrefsPayloadAttemptNumber[];
62extern const char kPrefsPreviousVersion[];
63extern const char kPrefsResumedUpdateFailures[];
Chris Sosaaa18e162013-06-20 13:20:30 -070064extern const char kPrefsRollbackVersion[];
Alex Deymo85616652015-10-15 18:48:31 -070065extern const char kPrefsChannelOnSlotPrefix[];
David Zeuthene4c58bf2013-06-18 17:26:50 -070066extern const char kPrefsSystemUpdatedMarker[];
Alex Deymo42432912013-07-12 20:21:15 -070067extern const char kPrefsTargetVersionAttempt[];
68extern const char kPrefsTargetVersionInstalledFrom[];
69extern const char kPrefsTargetVersionUniqueId[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070070extern const char kPrefsTotalBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070071extern const char kPrefsUpdateCheckCount[];
72extern const char kPrefsUpdateCheckResponseHash[];
Alex Deymo906191f2015-10-12 12:22:44 -070073extern const char kPrefsUpdateCompletedBootTime[];
74extern const char kPrefsUpdateCompletedOnBootId[];
David Zeuthencc6f9962013-04-18 11:57:24 -070075extern const char kPrefsUpdateDurationUptime[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070076extern const char kPrefsUpdateFirstSeenAt[];
Alex Deymof4867c42013-06-28 14:41:39 -070077extern const char kPrefsUpdateOverCellularPermission[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070078extern const char kPrefsUpdateServerCertificate[];
David Zeuthen41996ad2013-09-24 15:43:24 -070079extern const char kPrefsUpdateStateNextDataLength[];
David Zeuthen639aa362014-02-03 16:23:44 -080080extern const char kPrefsUpdateStateNextDataOffset[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070081extern const char kPrefsUpdateStateNextOperation[];
82extern const char kPrefsUpdateStateSHA256Context[];
83extern const char kPrefsUpdateStateSignatureBlob[];
84extern const char kPrefsUpdateStateSignedSHA256Context[];
David Zeuthen9a017f22013-04-11 16:10:26 -070085extern const char kPrefsUpdateTimestampStart[];
David Zeuthencc6f9962013-04-18 11:57:24 -070086extern const char kPrefsUrlSwitchCount[];
87extern const char kPrefsWallClockWaitPeriod[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070088
Alex Deymo98e691c2016-02-04 21:05:45 -080089// Keys used when storing and loading payload properties.
90extern const char kPayloadPropertyFileSize[];
91extern const char kPayloadPropertyFileHash[];
92extern const char kPayloadPropertyMetadataSize[];
93extern const char kPayloadPropertyMetadataHash[];
Alex Deymofdd6dec2016-03-03 22:35:43 -080094extern const char kPayloadPropertyAuthorization[];
95extern const char kPayloadPropertyUserAgent[];
Alex Deymofb905d92016-06-03 19:26:58 -070096extern const char kPayloadPropertyPowerwash[];
Alex Deymo87792ea2016-07-25 15:40:36 -070097extern const char kPayloadPropertyNetworkId[];
Alex Deymo98e691c2016-02-04 21:05:45 -080098
Jay Srinivasan19409b72013-04-12 19:23:36 -070099// A download source is any combination of protocol and server (that's of
100// interest to us when looking at UMA metrics) using which we may download
101// the payload.
102typedef enum {
Alex Vakulenkod2779df2014-06-16 13:19:00 -0700103 kDownloadSourceHttpsServer, // UMA Binary representation: 0001
104 kDownloadSourceHttpServer, // UMA Binary representation: 0010
105 kDownloadSourceHttpPeer, // UMA Binary representation: 0100
Jay Srinivasan19409b72013-04-12 19:23:36 -0700106
107 // Note: Add new sources only above this line.
108 kNumDownloadSources
109} DownloadSource;
110
Alex Deymo1c656c42013-06-28 11:02:14 -0700111// A payload can be a Full or Delta payload. In some cases, a Full payload is
112// used even when a Delta payload was available for the update, called here
113// ForcedFull. The PayloadType enum is only used to send UMA metrics about the
114// successfully applied payload.
115typedef enum {
116 kPayloadTypeFull,
117 kPayloadTypeDelta,
118 kPayloadTypeForcedFull,
119
120 // Note: Add new payload types only above this line.
121 kNumPayloadTypes
122} PayloadType;
123
David Zeuthen8f191b22013-08-06 12:27:50 -0700124// Maximum number of times we'll allow using p2p for the same update payload.
David Zeuthendcba8092013-08-06 12:16:35 -0700125const int kMaxP2PAttempts = 10;
126
David Zeuthen8f191b22013-08-06 12:27:50 -0700127// Maximum wallclock time we allow attempting to update using p2p for
David Zeuthen472b2052014-02-25 16:27:04 -0800128// the same update payload - five days.
129const int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60;
David Zeuthen8f191b22013-08-06 12:27:50 -0700130
131// The maximum amount of time to spend waiting for p2p-client(1) to
132// return while waiting in line to use the LAN - six hours.
133const int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60;
David Zeuthendcba8092013-08-06 12:16:35 -0700134
David Zeuthen526cb582013-08-06 12:26:18 -0700135// The maximum number of payload files to keep in /var/cache/p2p.
136const int kMaxP2PFilesToKeep = 3;
137
David Zeuthen41f2cf52014-11-05 12:29:45 -0500138// The maximum number of days to keep a p2p file;
139const int kMaxP2PFileAgeDays = 5;
140
Jay Srinivasan19409b72013-04-12 19:23:36 -0700141// The default number of UMA buckets for metrics.
142const int kNumDefaultUmaBuckets = 50;
143
144// General constants
145const int kNumBytesInOneMiB = 1024 * 1024;
146
David Zeuthen34135a92013-08-06 11:16:16 -0700147// Number of redirects allowed when downloading.
148const int kDownloadMaxRedirects = 10;
149
David Zeuthena641be52013-09-12 10:59:57 -0700150// The minimum average speed that downloads must sustain...
David Zeuthen34135a92013-08-06 11:16:16 -0700151//
152// This is set low because some devices may have very poor
Alex Vakulenko072359c2014-07-18 11:41:07 -0700153// connectivity and we want to make as much forward progress as
David Zeuthena641be52013-09-12 10:59:57 -0700154// possible. For p2p this is high (25 kB/second) since we can assume
David Zeuthen34135a92013-08-06 11:16:16 -0700155// high bandwidth (same LAN) and we want to fail fast.
156const int kDownloadLowSpeedLimitBps = 1;
David Zeuthena641be52013-09-12 10:59:57 -0700157const int kDownloadP2PLowSpeedLimitBps = 25 * 1000;
David Zeuthen34135a92013-08-06 11:16:16 -0700158
159// ... measured over this period.
160//
161// For non-official builds (e.g. typically built on a developer's
162// workstation and served via devserver) bump this since it takes time
163// for the workstation to generate the payload. For p2p, make this
164// relatively low since we want to fail fast.
165const int kDownloadLowSpeedTimeSeconds = 90;
166const int kDownloadDevModeLowSpeedTimeSeconds = 180;
David Zeuthena641be52013-09-12 10:59:57 -0700167const int kDownloadP2PLowSpeedTimeSeconds = 60;
David Zeuthen34135a92013-08-06 11:16:16 -0700168
169// The maximum amount of HTTP server reconnect attempts.
170//
171// This is set high in order to maximize the attempt's chance of
172// succeeding. When using p2p, this is low in order to fail fast.
173const int kDownloadMaxRetryCount = 20;
174const int kDownloadMaxRetryCountOobeNotComplete = 3;
David Zeuthena641be52013-09-12 10:59:57 -0700175const int kDownloadP2PMaxRetryCount = 5;
David Zeuthen34135a92013-08-06 11:16:16 -0700176
177// The connect timeout, in seconds.
178//
179// This is set high because some devices may have very poor
180// connectivity and we may be using HTTPS which involves complicated
181// multi-roundtrip setup. For p2p, this is set low because we can
182// the server is on the same LAN and we want to fail fast.
183const int kDownloadConnectTimeoutSeconds = 30;
184const int kDownloadP2PConnectTimeoutSeconds = 5;
185
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700186} // namespace chromeos_update_engine
187
Alex Deymo39910dc2015-11-09 17:04:30 -0800188#endif // UPDATE_ENGINE_COMMON_CONSTANTS_H_