constants.h 8.2 KB

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