blob: 34013e8812d20fba686a3506d0326899c45325e5 [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_CONSTANTS_H_
18#define UPDATE_ENGINE_CONSTANTS_H_
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070019
20namespace 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.
24extern const char kPowerwashMarkerFile[];
25
26// The contents of the powerwash marker file.
27extern const char kPowerwashCommand[];
28
Chris Sosaaa18e162013-06-20 13:20:30 -070029// Directory for AU prefs that are preserved across powerwash.
Alex Deymodd132f32015-09-14 19:12:07 -070030extern const char kPowerwashSafePrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070031
32// The location where we store the AU preferences (state etc).
Alex Deymodd132f32015-09-14 19:12:07 -070033extern const char kPrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070034
Chris Sosabe45bef2013-04-09 18:25:12 -070035// Path to the stateful partition on the root filesystem.
36extern const char kStatefulPartition[];
37
Jay Srinivasand29695d2013-04-08 15:08:05 -070038// Constants related to preferences.
David Zeuthen4e1d1492014-04-25 13:12:27 -070039extern const char kPrefsAttemptInProgress[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070040extern const char kPrefsBackoffExpiryTime[];
Alex Deymodd132f32015-09-14 19:12:07 -070041extern const char kPrefsBootId[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070042extern const char kPrefsCertificateReportToSendDownload[];
43extern const char kPrefsCertificateReportToSendUpdate[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070044extern const char kPrefsCurrentBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070045extern const char kPrefsCurrentResponseSignature[];
46extern const char kPrefsCurrentUrlFailureCount[];
47extern const char kPrefsCurrentUrlIndex[];
David Zeuthen985b1122013-10-09 12:13:15 -070048extern const char kPrefsDailyMetricsLastReportedAt[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070049extern const char kPrefsDeltaUpdateFailures[];
Alex Deymo820cc702013-06-28 15:43:46 -070050extern const char kPrefsFullPayloadAttemptNumber[];
David Zeuthen639aa362014-02-03 16:23:44 -080051extern const char kPrefsInstallDateDays[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070052extern const char kPrefsLastActivePingDay[];
53extern const char kPrefsLastRollCallPingDay[];
54extern const char kPrefsManifestMetadataSize[];
David Zeuthen33bae492014-02-25 16:16:18 -080055extern const char kPrefsMetricsAttemptLastReportingTime[];
56extern const char kPrefsMetricsCheckLastReportingTime[];
Chris Sosabe45bef2013-04-09 18:25:12 -070057extern const char kPrefsNumReboots[];
David Zeuthena573d6f2013-06-14 16:13:36 -070058extern const char kPrefsNumResponsesSeen[];
Alex Deymo8e18f932015-03-27 16:16:59 -070059extern const char kPrefsOmahaCohort[];
60extern const char kPrefsOmahaCohortHint[];
61extern const char kPrefsOmahaCohortName[];
David Zeuthen27a48bc2013-08-06 12:06:29 -070062extern const char kPrefsP2PEnabled[];
David Zeuthen639aa362014-02-03 16:23:44 -080063extern const char kPrefsP2PFirstAttemptTimestamp[];
64extern const char kPrefsP2PNumAttempts[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070065extern const char kPrefsPayloadAttemptNumber[];
66extern const char kPrefsPreviousVersion[];
67extern const char kPrefsResumedUpdateFailures[];
Chris Sosaaa18e162013-06-20 13:20:30 -070068extern const char kPrefsRollbackVersion[];
Alex Deymo85616652015-10-15 18:48:31 -070069extern const char kPrefsChannelOnSlotPrefix[];
David Zeuthene4c58bf2013-06-18 17:26:50 -070070extern const char kPrefsSystemUpdatedMarker[];
Alex Deymo42432912013-07-12 20:21:15 -070071extern const char kPrefsTargetVersionAttempt[];
72extern const char kPrefsTargetVersionInstalledFrom[];
73extern const char kPrefsTargetVersionUniqueId[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070074extern const char kPrefsTotalBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070075extern const char kPrefsUpdateCheckCount[];
76extern const char kPrefsUpdateCheckResponseHash[];
Alex Deymo906191f2015-10-12 12:22:44 -070077extern const char kPrefsUpdateCompletedBootTime[];
78extern const char kPrefsUpdateCompletedOnBootId[];
David Zeuthencc6f9962013-04-18 11:57:24 -070079extern const char kPrefsUpdateDurationUptime[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070080extern const char kPrefsUpdateFirstSeenAt[];
Alex Deymof4867c42013-06-28 14:41:39 -070081extern const char kPrefsUpdateOverCellularPermission[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070082extern const char kPrefsUpdateServerCertificate[];
David Zeuthen41996ad2013-09-24 15:43:24 -070083extern const char kPrefsUpdateStateNextDataLength[];
David Zeuthen639aa362014-02-03 16:23:44 -080084extern const char kPrefsUpdateStateNextDataOffset[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070085extern const char kPrefsUpdateStateNextOperation[];
86extern const char kPrefsUpdateStateSHA256Context[];
87extern const char kPrefsUpdateStateSignatureBlob[];
88extern const char kPrefsUpdateStateSignedSHA256Context[];
David Zeuthen9a017f22013-04-11 16:10:26 -070089extern const char kPrefsUpdateTimestampStart[];
David Zeuthencc6f9962013-04-18 11:57:24 -070090extern const char kPrefsUrlSwitchCount[];
91extern const char kPrefsWallClockWaitPeriod[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070092
Jay Srinivasan19409b72013-04-12 19:23:36 -070093// A download source is any combination of protocol and server (that's of
94// interest to us when looking at UMA metrics) using which we may download
95// the payload.
96typedef enum {
Alex Vakulenkod2779df2014-06-16 13:19:00 -070097 kDownloadSourceHttpsServer, // UMA Binary representation: 0001
98 kDownloadSourceHttpServer, // UMA Binary representation: 0010
99 kDownloadSourceHttpPeer, // UMA Binary representation: 0100
Jay Srinivasan19409b72013-04-12 19:23:36 -0700100
101 // Note: Add new sources only above this line.
102 kNumDownloadSources
103} DownloadSource;
104
Alex Deymo1c656c42013-06-28 11:02:14 -0700105// A payload can be a Full or Delta payload. In some cases, a Full payload is
106// used even when a Delta payload was available for the update, called here
107// ForcedFull. The PayloadType enum is only used to send UMA metrics about the
108// successfully applied payload.
109typedef enum {
110 kPayloadTypeFull,
111 kPayloadTypeDelta,
112 kPayloadTypeForcedFull,
113
114 // Note: Add new payload types only above this line.
115 kNumPayloadTypes
116} PayloadType;
117
David Zeuthen8f191b22013-08-06 12:27:50 -0700118// Maximum number of times we'll allow using p2p for the same update payload.
David Zeuthendcba8092013-08-06 12:16:35 -0700119const int kMaxP2PAttempts = 10;
120
David Zeuthen8f191b22013-08-06 12:27:50 -0700121// Maximum wallclock time we allow attempting to update using p2p for
David Zeuthen472b2052014-02-25 16:27:04 -0800122// the same update payload - five days.
123const int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60;
David Zeuthen8f191b22013-08-06 12:27:50 -0700124
125// The maximum amount of time to spend waiting for p2p-client(1) to
126// return while waiting in line to use the LAN - six hours.
127const int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60;
David Zeuthendcba8092013-08-06 12:16:35 -0700128
David Zeuthen526cb582013-08-06 12:26:18 -0700129// The maximum number of payload files to keep in /var/cache/p2p.
130const int kMaxP2PFilesToKeep = 3;
131
David Zeuthen41f2cf52014-11-05 12:29:45 -0500132// The maximum number of days to keep a p2p file;
133const int kMaxP2PFileAgeDays = 5;
134
Jay Srinivasan19409b72013-04-12 19:23:36 -0700135// The default number of UMA buckets for metrics.
136const int kNumDefaultUmaBuckets = 50;
137
138// General constants
139const int kNumBytesInOneMiB = 1024 * 1024;
140
David Zeuthen34135a92013-08-06 11:16:16 -0700141// Number of redirects allowed when downloading.
142const int kDownloadMaxRedirects = 10;
143
David Zeuthena641be52013-09-12 10:59:57 -0700144// The minimum average speed that downloads must sustain...
David Zeuthen34135a92013-08-06 11:16:16 -0700145//
146// This is set low because some devices may have very poor
Alex Vakulenko072359c2014-07-18 11:41:07 -0700147// connectivity and we want to make as much forward progress as
David Zeuthena641be52013-09-12 10:59:57 -0700148// possible. For p2p this is high (25 kB/second) since we can assume
David Zeuthen34135a92013-08-06 11:16:16 -0700149// high bandwidth (same LAN) and we want to fail fast.
150const int kDownloadLowSpeedLimitBps = 1;
David Zeuthena641be52013-09-12 10:59:57 -0700151const int kDownloadP2PLowSpeedLimitBps = 25 * 1000;
David Zeuthen34135a92013-08-06 11:16:16 -0700152
153// ... measured over this period.
154//
155// For non-official builds (e.g. typically built on a developer's
156// workstation and served via devserver) bump this since it takes time
157// for the workstation to generate the payload. For p2p, make this
158// relatively low since we want to fail fast.
159const int kDownloadLowSpeedTimeSeconds = 90;
160const int kDownloadDevModeLowSpeedTimeSeconds = 180;
David Zeuthena641be52013-09-12 10:59:57 -0700161const int kDownloadP2PLowSpeedTimeSeconds = 60;
David Zeuthen34135a92013-08-06 11:16:16 -0700162
163// The maximum amount of HTTP server reconnect attempts.
164//
165// This is set high in order to maximize the attempt's chance of
166// succeeding. When using p2p, this is low in order to fail fast.
167const int kDownloadMaxRetryCount = 20;
168const int kDownloadMaxRetryCountOobeNotComplete = 3;
David Zeuthena641be52013-09-12 10:59:57 -0700169const int kDownloadP2PMaxRetryCount = 5;
David Zeuthen34135a92013-08-06 11:16:16 -0700170
171// The connect timeout, in seconds.
172//
173// This is set high because some devices may have very poor
174// connectivity and we may be using HTTPS which involves complicated
175// multi-roundtrip setup. For p2p, this is set low because we can
176// the server is on the same LAN and we want to fail fast.
177const int kDownloadConnectTimeoutSeconds = 30;
178const int kDownloadP2PConnectTimeoutSeconds = 5;
179
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700180} // namespace chromeos_update_engine
181
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700182#endif // UPDATE_ENGINE_CONSTANTS_H_