blob: 68f720dbe487ebdc562e41cd10597d1ea695e52d [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
Kelvin Zhangec205cf2020-09-28 13:23:40 -040020#include <cstdint>
21
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070022namespace chromeos_update_engine {
23
Jae Hoon Kim38de3b12020-04-29 19:41:23 -070024// The root path of all exclusion prefs.
25extern const char kExclusionPrefsSubDir[];
26
Andrew065d78d2020-04-07 15:43:07 -070027// The root path of all DLC metadata.
28extern const char kDlcPrefsSubDir[];
Andrewe045aef2020-01-08 16:29:22 -080029
Chris Sosaaa18e162013-06-20 13:20:30 -070030// Directory for AU prefs that are preserved across powerwash.
Alex Deymodd132f32015-09-14 19:12:07 -070031extern const char kPowerwashSafePrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070032
33// The location where we store the AU preferences (state etc).
Alex Deymodd132f32015-09-14 19:12:07 -070034extern const char kPrefsSubDirectory[];
Chris Sosaaa18e162013-06-20 13:20:30 -070035
Alex Deymo390efed2016-02-18 11:00:40 -080036// Path to the post install command, relative to the partition.
37extern const char kPostinstallDefaultScript[];
38
Chris Sosabe45bef2013-04-09 18:25:12 -070039// Path to the stateful partition on the root filesystem.
40extern const char kStatefulPartition[];
41
Jay Srinivasand29695d2013-04-08 15:08:05 -070042// Constants related to preferences.
David Zeuthen4e1d1492014-04-25 13:12:27 -070043extern const char kPrefsAttemptInProgress[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070044extern const char kPrefsBackoffExpiryTime[];
Alex Deymodd132f32015-09-14 19:12:07 -070045extern const char kPrefsBootId[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070046extern const char kPrefsCurrentBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070047extern const char kPrefsCurrentResponseSignature[];
48extern const char kPrefsCurrentUrlFailureCount[];
49extern const char kPrefsCurrentUrlIndex[];
David Zeuthen985b1122013-10-09 12:13:15 -070050extern const char kPrefsDailyMetricsLastReportedAt[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070051extern const char kPrefsDeltaUpdateFailures[];
Tao Bao3406c772019-01-02 15:34:35 -080052extern const char kPrefsDynamicPartitionMetadataUpdated[];
Alex Deymo820cc702013-06-28 15:43:46 -070053extern const char kPrefsFullPayloadAttemptNumber[];
David Zeuthen639aa362014-02-03 16:23:44 -080054extern const char kPrefsInstallDateDays[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070055extern const char kPrefsLastActivePingDay[];
56extern const char kPrefsLastRollCallPingDay[];
57extern const char kPrefsManifestMetadataSize[];
Alex Deymof25eb492016-02-26 00:20:08 -080058extern const char kPrefsManifestSignatureSize[];
David Zeuthen33bae492014-02-25 16:16:18 -080059extern const char kPrefsMetricsAttemptLastReportingTime[];
60extern const char kPrefsMetricsCheckLastReportingTime[];
Amin Hassaniffb6d802018-03-30 11:43:57 -070061extern const char kPrefsNoIgnoreBackoff[];
Chris Sosabe45bef2013-04-09 18:25:12 -070062extern const char kPrefsNumReboots[];
David Zeuthena573d6f2013-06-14 16:13:36 -070063extern const char kPrefsNumResponsesSeen[];
Alex Deymo8e18f932015-03-27 16:16:59 -070064extern const char kPrefsOmahaCohort[];
65extern const char kPrefsOmahaCohortHint[];
66extern const char kPrefsOmahaCohortName[];
Jae Hoon Kim051627a2019-09-03 12:56:32 -070067extern const char kPrefsOmahaEolDate[];
David Zeuthen27a48bc2013-08-06 12:06:29 -070068extern const char kPrefsP2PEnabled[];
David Zeuthen639aa362014-02-03 16:23:44 -080069extern const char kPrefsP2PFirstAttemptTimestamp[];
70extern const char kPrefsP2PNumAttempts[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070071extern const char kPrefsPayloadAttemptNumber[];
Amin Hassani03277de2020-07-28 12:32:49 -070072extern const char kPrefsTestUpdateCheckIntervalTimeout[];
Andrewe045aef2020-01-08 16:29:22 -080073extern const char kPrefsPingActive[];
74extern const char kPrefsPingLastActive[];
75extern const char kPrefsPingLastRollcall[];
Vyshu Khota4c5413d2020-11-04 16:17:25 -080076extern const char kPrefsLastFp[];
Sen Jiang02c49422017-10-31 15:14:11 -070077extern const char kPrefsPostInstallSucceeded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070078extern const char kPrefsPreviousVersion[];
Kelvin Zhang86603472021-05-11 12:16:27 -040079extern const char kPrefsPreviousSlot[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070080extern const char kPrefsResumedUpdateFailures[];
Marton Hunyadye58bddb2018-04-10 20:27:26 +020081extern const char kPrefsRollbackHappened[];
Chris Sosaaa18e162013-06-20 13:20:30 -070082extern const char kPrefsRollbackVersion[];
Alex Deymo85616652015-10-15 18:48:31 -070083extern const char kPrefsChannelOnSlotPrefix[];
David Zeuthene4c58bf2013-06-18 17:26:50 -070084extern const char kPrefsSystemUpdatedMarker[];
Alex Deymo42432912013-07-12 20:21:15 -070085extern const char kPrefsTargetVersionAttempt[];
86extern const char kPrefsTargetVersionInstalledFrom[];
87extern const char kPrefsTargetVersionUniqueId[];
Jay Srinivasan19409b72013-04-12 19:23:36 -070088extern const char kPrefsTotalBytesDownloaded[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070089extern const char kPrefsUpdateCheckCount[];
90extern const char kPrefsUpdateCheckResponseHash[];
Alex Deymo906191f2015-10-12 12:22:44 -070091extern const char kPrefsUpdateCompletedBootTime[];
92extern const char kPrefsUpdateCompletedOnBootId[];
David Zeuthencc6f9962013-04-18 11:57:24 -070093extern const char kPrefsUpdateDurationUptime[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070094extern const char kPrefsUpdateFirstSeenAt[];
Alex Deymof4867c42013-06-28 14:41:39 -070095extern const char kPrefsUpdateOverCellularPermission[];
Weidong Guo421ff332017-04-17 10:08:38 -070096extern const char kPrefsUpdateOverCellularTargetVersion[];
97extern const char kPrefsUpdateOverCellularTargetSize[];
Jay Srinivasand29695d2013-04-08 15:08:05 -070098extern const char kPrefsUpdateServerCertificate[];
David Zeuthen41996ad2013-09-24 15:43:24 -070099extern const char kPrefsUpdateStateNextDataLength[];
David Zeuthen639aa362014-02-03 16:23:44 -0800100extern const char kPrefsUpdateStateNextDataOffset[];
Jay Srinivasand29695d2013-04-08 15:08:05 -0700101extern const char kPrefsUpdateStateNextOperation[];
Sen Jiang0affc2c2017-02-10 15:55:05 -0800102extern const char kPrefsUpdateStatePayloadIndex[];
Jay Srinivasand29695d2013-04-08 15:08:05 -0700103extern const char kPrefsUpdateStateSHA256Context[];
104extern const char kPrefsUpdateStateSignatureBlob[];
105extern const char kPrefsUpdateStateSignedSHA256Context[];
Tianjie Xu2a0ea632018-08-06 12:59:23 -0700106extern const char kPrefsUpdateBootTimestampStart[];
David Zeuthen9a017f22013-04-11 16:10:26 -0700107extern const char kPrefsUpdateTimestampStart[];
David Zeuthencc6f9962013-04-18 11:57:24 -0700108extern const char kPrefsUrlSwitchCount[];
Sen Jiang3eeaf7d2018-10-11 13:55:32 -0700109extern const char kPrefsVerityWritten[];
Adolfo Victoriad3a1e352018-07-16 11:40:47 -0700110extern const char kPrefsWallClockScatteringWaitPeriod[];
111extern const char kPrefsWallClockStagingWaitPeriod[];
Kelvin Zhangcc011d32020-07-10 18:20:08 -0400112extern const char kPrefsManifestBytes[];
Jay Srinivasand29695d2013-04-08 15:08:05 -0700113
Alex Deymo98e691c2016-02-04 21:05:45 -0800114// Keys used when storing and loading payload properties.
115extern const char kPayloadPropertyFileSize[];
116extern const char kPayloadPropertyFileHash[];
117extern const char kPayloadPropertyMetadataSize[];
118extern const char kPayloadPropertyMetadataHash[];
Alex Deymofdd6dec2016-03-03 22:35:43 -0800119extern const char kPayloadPropertyAuthorization[];
120extern const char kPayloadPropertyUserAgent[];
Alex Deymofb905d92016-06-03 19:26:58 -0700121extern const char kPayloadPropertyPowerwash[];
Alex Deymo87792ea2016-07-25 15:40:36 -0700122extern const char kPayloadPropertyNetworkId[];
Sen Jiang02c49422017-10-31 15:14:11 -0700123extern const char kPayloadPropertySwitchSlotOnReboot[];
124extern const char kPayloadPropertyRunPostInstall[];
Alex Deymo98e691c2016-02-04 21:05:45 -0800125
Amin Hassani7fca2862019-03-28 16:09:22 -0700126extern const char kOmahaUpdaterVersion[];
127
Jae Hoon Kim0ae8fe12019-06-26 14:32:50 -0700128// X-Goog-Update headers.
129extern const char kXGoogleUpdateInteractivity[];
130extern const char kXGoogleUpdateAppId[];
131extern const char kXGoogleUpdateUpdater[];
132extern const char kXGoogleUpdateSessionId[];
133
Jay Srinivasan19409b72013-04-12 19:23:36 -0700134// 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.
137typedef enum {
Alex Vakulenkod2779df2014-06-16 13:19:00 -0700138 kDownloadSourceHttpsServer, // UMA Binary representation: 0001
139 kDownloadSourceHttpServer, // UMA Binary representation: 0010
140 kDownloadSourceHttpPeer, // UMA Binary representation: 0100
Jay Srinivasan19409b72013-04-12 19:23:36 -0700141
142 // Note: Add new sources only above this line.
143 kNumDownloadSources
144} DownloadSource;
145
Alex Deymo1c656c42013-06-28 11:02:14 -0700146// 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.
150typedef enum {
151 kPayloadTypeFull,
152 kPayloadTypeDelta,
153 kPayloadTypeForcedFull,
154
155 // Note: Add new payload types only above this line.
156 kNumPayloadTypes
157} PayloadType;
158
David Zeuthen8f191b22013-08-06 12:27:50 -0700159// Maximum number of times we'll allow using p2p for the same update payload.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400160constexpr int kMaxP2PAttempts = 10;
David Zeuthendcba8092013-08-06 12:16:35 -0700161
David Zeuthen8f191b22013-08-06 12:27:50 -0700162// Maximum wallclock time we allow attempting to update using p2p for
David Zeuthen472b2052014-02-25 16:27:04 -0800163// the same update payload - five days.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400164constexpr int kMaxP2PAttemptTimeSeconds = 5 * 24 * 60 * 60;
David Zeuthen8f191b22013-08-06 12:27:50 -0700165
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.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400168constexpr int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60;
David Zeuthendcba8092013-08-06 12:16:35 -0700169
David Zeuthen526cb582013-08-06 12:26:18 -0700170// The maximum number of payload files to keep in /var/cache/p2p.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400171constexpr int kMaxP2PFilesToKeep = 3;
David Zeuthen526cb582013-08-06 12:26:18 -0700172
David Zeuthen41f2cf52014-11-05 12:29:45 -0500173// The maximum number of days to keep a p2p file;
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400174constexpr int kMaxP2PFileAgeDays = 5;
David Zeuthen41f2cf52014-11-05 12:29:45 -0500175
Jay Srinivasan19409b72013-04-12 19:23:36 -0700176// The default number of UMA buckets for metrics.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400177constexpr int kNumDefaultUmaBuckets = 50;
Jay Srinivasan19409b72013-04-12 19:23:36 -0700178
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400179// General constexprants
180constexpr int kNumBytesInOneMiB = 1024 * 1024;
Jay Srinivasan19409b72013-04-12 19:23:36 -0700181
David Zeuthen34135a92013-08-06 11:16:16 -0700182// Number of redirects allowed when downloading.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400183constexpr int kDownloadMaxRedirects = 10;
David Zeuthen34135a92013-08-06 11:16:16 -0700184
David Zeuthena641be52013-09-12 10:59:57 -0700185// The minimum average speed that downloads must sustain...
David Zeuthen34135a92013-08-06 11:16:16 -0700186//
187// This is set low because some devices may have very poor
Alex Vakulenko072359c2014-07-18 11:41:07 -0700188// connectivity and we want to make as much forward progress as
David Zeuthena641be52013-09-12 10:59:57 -0700189// possible. For p2p this is high (25 kB/second) since we can assume
David Zeuthen34135a92013-08-06 11:16:16 -0700190// high bandwidth (same LAN) and we want to fail fast.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400191constexpr int kDownloadLowSpeedLimitBps = 1;
192constexpr int kDownloadP2PLowSpeedLimitBps = 25 * 1000;
David Zeuthen34135a92013-08-06 11:16:16 -0700193
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
Aaron Wood22290592018-03-09 09:19:15 -0800198// 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.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400201constexpr int kDownloadLowSpeedTimeSeconds = 30;
202constexpr int kDownloadDevModeLowSpeedTimeSeconds = 180;
203constexpr int kDownloadP2PLowSpeedTimeSeconds = 60;
David Zeuthen34135a92013-08-06 11:16:16 -0700204
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.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400209constexpr int kDownloadMaxRetryCount = 20;
210constexpr int kDownloadMaxRetryCountOobeNotComplete = 3;
211constexpr int kDownloadMaxRetryCountInteractive = 3;
212constexpr int kDownloadP2PMaxRetryCount = 5;
David Zeuthen34135a92013-08-06 11:16:16 -0700213
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.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400220constexpr int kDownloadConnectTimeoutSeconds = 30;
221constexpr int kDownloadP2PConnectTimeoutSeconds = 5;
David Zeuthen34135a92013-08-06 11:16:16 -0700222
xunchangcda3c032019-03-26 15:41:14 -0700223// Size in bytes of SHA256 hash.
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400224constexpr 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.
232constexpr uint64_t kEndOfInstallLabel = (1ULL << 48);
xunchangcda3c032019-03-26 15:41:14 -0700233
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700234} // namespace chromeos_update_engine
235
Alex Deymo39910dc2015-11-09 17:04:30 -0800236#endif // UPDATE_ENGINE_COMMON_CONSTANTS_H_