forked from AndDiSa/platform_manifest-Grouper-AOSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_engine.patch
554 lines (505 loc) · 20 KB
/
update_engine.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
diff --git a/common/error_code.h b/common/error_code.h
index 32155f27..3800bf0f 100644
--- a/common/error_code.h
+++ b/common/error_code.h
@@ -72,6 +72,9 @@ enum class ErrorCode : int {
kOmahaRequestXMLHasEntityDecl = 46,
kFilesystemVerifierError = 47,
kUserCanceled = 48,
+ kNonCriticalUpdateInOOBE = 49,
+ // kOmahaUpdateIgnoredOverCellular = 50,
+ kPayloadTimestampError = 51,
// VERY IMPORTANT! When adding new error codes:
//
diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc
index dc9eaf4a..0a015eb2 100644
--- a/common/error_code_utils.cc
+++ b/common/error_code_utils.cc
@@ -142,6 +142,10 @@ string ErrorCodeToString(ErrorCode code) {
return "ErrorCode::kFilesystemVerifierError";
case ErrorCode::kUserCanceled:
return "ErrorCode::kUserCanceled";
+ case ErrorCode::kNonCriticalUpdateInOOBE:
+ return "ErrorCode::kNonCriticalUpdateInOOBE";
+ case ErrorCode::kPayloadTimestampError:
+ return "ErrorCode::kPayloadTimestampError";
// Don't add a default case to let the compiler warn about newly added
// error codes which should be added here.
}
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index 0bd297bf..25324aec 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -82,6 +82,8 @@ class FakeHardware : public HardwareInterface {
return false;
}
+ int64_t GetBuildTimestamp() const override { return build_timestamp_; }
+
// Setters
void SetIsOfficialBuild(bool is_official_build) {
is_official_build_ = is_official_build;
@@ -118,6 +120,10 @@ class FakeHardware : public HardwareInterface {
powerwash_count_ = powerwash_count;
}
+ void SetBuildTimestamp(int64_t build_timestamp) {
+ build_timestamp_ = build_timestamp;
+ }
+
private:
bool is_official_build_;
bool is_normal_boot_mode_;
@@ -128,6 +134,7 @@ class FakeHardware : public HardwareInterface {
std::string ec_version_;
int powerwash_count_;
bool powerwash_scheduled_{false};
+ int64_t build_timestamp_{0};
DISALLOW_COPY_AND_ASSIGN(FakeHardware);
};
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index c2d42964..d5f73f78 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -17,6 +17,8 @@
#ifndef UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_
#define UPDATE_ENGINE_COMMON_HARDWARE_INTERFACE_H_
+#include <stdint.h>
+
#include <string>
#include <vector>
@@ -81,6 +83,9 @@ class HardwareInterface {
// powerwash cycles. In case of an error, such as no directory available,
// returns false.
virtual bool GetPowerwashSafeDirectory(base::FilePath* path) const = 0;
+
+ // Returns the timestamp of the current OS build.
+ virtual int64_t GetBuildTimestamp() const = 0;
};
} // namespace chromeos_update_engine
diff --git a/hardware_android.cc b/hardware_android.cc
index 778f8ad9..9490c24a 100644
--- a/hardware_android.cc
+++ b/hardware_android.cc
@@ -25,6 +25,7 @@
#include <bootloader.h>
#include <base/files/file_util.h>
+#include <base/strings/stringprintf.h>
#include <brillo/make_unique_ptr.h>
#include <cutils/properties.h>
@@ -45,6 +46,16 @@ const char kAndroidRecoveryPowerwashCommand[] =
"--wipe_data\n"
"--reason=wipe_data_from_ota\n";
+// Android properties that identify the hardware and potentially non-updatable
+// parts of the bootloader (such as the bootloader version and the baseband
+// version).
+const char kPropBootBootloader[] = "ro.boot.bootloader";
+const char kPropBootBaseband[] = "ro.boot.baseband";
+const char kPropProductManufacturer[] = "ro.product.manufacturer";
+const char kPropBootHardwareSKU[] = "ro.boot.hardware.sku";
+const char kPropBootRevision[] = "ro.boot.revision";
+const char kPropBuildDateUTC[] = "ro.build.date.utc";
+
// Write a recovery command line |message| to the BCB. The arguments to recovery
// must be separated by '\n'. An empty string will erase the BCB.
bool WriteBootloaderRecoveryMessage(const string& message) {
@@ -122,26 +133,43 @@ bool HardwareAndroid::IsNormalBootMode() const {
return property_get_bool("ro.debuggable", 0) != 1;
}
+bool HardwareAndroid::AreDevFeaturesEnabled() const {
+ return !IsNormalBootMode();
+}
+
+bool HardwareAndroid::IsOOBEEnabled() const {
+ // No OOBE flow blocking updates for Android-based boards.
+ return false;
+}
+
bool HardwareAndroid::IsOOBEComplete(base::Time* out_time_of_oobe) const {
- LOG(WARNING) << "STUB: Assuming OOBE is complete.";
+ LOG(WARNING) << "OOBE is not enabled but IsOOBEComplete() called.";
if (out_time_of_oobe)
*out_time_of_oobe = base::Time();
return true;
}
string HardwareAndroid::GetHardwareClass() const {
- LOG(WARNING) << "STUB: GetHardwareClass().";
- return "ANDROID";
+ char manufacturer[PROPERTY_VALUE_MAX];
+ char sku[PROPERTY_VALUE_MAX];
+ char revision[PROPERTY_VALUE_MAX];
+ property_get(kPropBootHardwareSKU, sku, "");
+ property_get(kPropProductManufacturer, manufacturer, "");
+ property_get(kPropBootRevision, revision, "");
+
+ return base::StringPrintf("%s:%s:%s", manufacturer, sku, revision);
}
string HardwareAndroid::GetFirmwareVersion() const {
- LOG(WARNING) << "STUB: GetFirmwareVersion().";
- return "0";
+ char bootloader[PROPERTY_VALUE_MAX];
+ property_get(kPropBootBootloader, bootloader, "");
+ return bootloader;
}
string HardwareAndroid::GetECVersion() const {
- LOG(WARNING) << "STUB: GetECVersion().";
- return "0";
+ char baseband[PROPERTY_VALUE_MAX];
+ property_get(kPropBootBaseband, baseband, "");
+ return baseband;
}
int HardwareAndroid::GetPowerwashCount() const {
@@ -173,4 +201,8 @@ bool HardwareAndroid::GetPowerwashSafeDirectory(base::FilePath* path) const {
return false;
}
+int64_t HardwareAndroid::GetBuildTimestamp() const {
+ return property_get_int64(kPropBuildDateUTC, 0);
+}
+
} // namespace chromeos_update_engine
diff --git a/hardware_android.h b/hardware_android.h
index 4ea34042..65613774 100644
--- a/hardware_android.h
+++ b/hardware_android.h
@@ -45,6 +45,7 @@ class HardwareAndroid final : public HardwareInterface {
bool CancelPowerwash() override;
bool GetNonVolatileDirectory(base::FilePath* path) const override;
bool GetPowerwashSafeDirectory(base::FilePath* path) const override;
+ int64_t GetBuildTimestamp() const override;
private:
DISALLOW_COPY_AND_ASSIGN(HardwareAndroid);
diff --git a/hardware_chromeos.cc b/hardware_chromeos.cc
index 85131fc4..f0f3ea98 100644
--- a/hardware_chromeos.cc
+++ b/hardware_chromeos.cc
@@ -16,22 +16,27 @@
#include "update_engine/hardware_chromeos.h"
+#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
+#include <brillo/key_value_store.h>
#include <brillo/make_unique_ptr.h>
+#include <debugd/dbus-constants.h>
#include <vboot/crossystem.h>
extern "C" {
#include "vboot/vboot_host.h"
}
+#include "update_engine/common/constants.h"
#include "update_engine/common/hardware.h"
#include "update_engine/common/hwid_override.h"
#include "update_engine/common/platform_constants.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/utils.h"
+#include "update_engine/dbus_connection.h"
using std::string;
using std::vector;
@@ -50,6 +55,14 @@ const char kPowerwashSafeDirectory[] =
// a powerwash is performed.
const char kPowerwashCountMarker[] = "powerwash_count";
+// The name of the marker file used to trigger powerwash when post-install
+// completes successfully so that the device is powerwashed on next reboot.
+const char kPowerwashMarkerFile[] =
+ "/mnt/stateful_partition/factory_install_reset";
+
+// The contents of the powerwash marker file.
+const char kPowerwashCommand[] = "safe fast keepimg reason=update_engine\n";
+
// UpdateManager config path.
const char* kConfigFilePath = "/etc/update_manager.conf";
@@ -64,11 +77,19 @@ namespace hardware {
// Factory defined in hardware.h.
std::unique_ptr<HardwareInterface> CreateHardware() {
- return brillo::make_unique_ptr(new HardwareChromeOS());
+ std::unique_ptr<HardwareChromeOS> hardware(new HardwareChromeOS());
+ hardware->Init();
+ return std::move(hardware);
}
} // namespace hardware
+void HardwareChromeOS::Init() {
+ LoadConfig("" /* root_prefix */, IsNormalBootMode());
+ debugd_proxy_.reset(
+ new org::chromium::debugdProxy(DBusConnection::Get()->GetDBus()));
+}
+
bool HardwareChromeOS::IsOfficialBuild() const {
return VbGetSystemPropertyInt("debug_build") == 0;
}
@@ -78,7 +99,32 @@ bool HardwareChromeOS::IsNormalBootMode() const {
return !dev_mode;
}
+bool HardwareChromeOS::AreDevFeaturesEnabled() const {
+ // Even though the debugd tools are also gated on devmode, checking here can
+ // save us a D-Bus call so it's worth doing explicitly.
+ if (IsNormalBootMode())
+ return false;
+
+ int32_t dev_features = debugd::DEV_FEATURES_DISABLED;
+ brillo::ErrorPtr error;
+ // Some boards may not include debugd so it's expected that this may fail,
+ // in which case we treat it as disabled.
+ if (debugd_proxy_ && debugd_proxy_->QueryDevFeatures(&dev_features, &error) &&
+ !(dev_features & debugd::DEV_FEATURES_DISABLED)) {
+ LOG(INFO) << "Debugd dev tools enabled.";
+ return true;
+ }
+ return false;
+}
+
+bool HardwareChromeOS::IsOOBEEnabled() const {
+ return is_oobe_enabled_;
+}
+
bool HardwareChromeOS::IsOOBEComplete(base::Time* out_time_of_oobe) const {
+ if (!is_oobe_enabled_) {
+ LOG(WARNING) << "OOBE is not enabled but IsOOBEComplete() was called";
+ }
struct stat statbuf;
if (stat(kOOBECompletedMarker, &statbuf) != 0) {
if (errno != ENOENT) {
@@ -150,9 +196,11 @@ bool HardwareChromeOS::SchedulePowerwash() {
bool result = utils::WriteFile(
kPowerwashMarkerFile, kPowerwashCommand, strlen(kPowerwashCommand));
if (result) {
- LOG(INFO) << "Created " << marker_file << " to powerwash on next reboot";
+ LOG(INFO) << "Created " << kPowerwashMarkerFile
+ << " to powerwash on next reboot";
} else {
- PLOG(ERROR) << "Error in creating powerwash marker file: " << marker_file;
+ PLOG(ERROR) << "Error in creating powerwash marker file: "
+ << kPowerwashMarkerFile;
}
return result;
@@ -163,10 +211,10 @@ bool HardwareChromeOS::CancelPowerwash() {
if (result) {
LOG(INFO) << "Successfully deleted the powerwash marker file : "
- << marker_file;
+ << kPowerwashMarkerFile;
} else {
PLOG(ERROR) << "Could not delete the powerwash marker file : "
- << marker_file;
+ << kPowerwashMarkerFile;
}
return result;
@@ -182,4 +230,27 @@ bool HardwareChromeOS::GetPowerwashSafeDirectory(base::FilePath* path) const {
return true;
}
+int64_t HardwareChromeOS::GetBuildTimestamp() const {
+ // TODO(senj): implement this in Chrome OS.
+ return 0;
+}
+
+void HardwareChromeOS::LoadConfig(const string& root_prefix, bool normal_mode) {
+ brillo::KeyValueStore store;
+
+ if (normal_mode) {
+ store.Load(base::FilePath(root_prefix + kConfigFilePath));
+ } else {
+ if (store.Load(base::FilePath(root_prefix + kStatefulPartition +
+ kConfigFilePath))) {
+ LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
+ } else {
+ store.Load(base::FilePath(root_prefix + kConfigFilePath));
+ }
+ }
+
+ if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled_))
+ is_oobe_enabled_ = true; // Default value.
+}
+
} // namespace chromeos_update_engine
diff --git a/hardware_chromeos.h b/hardware_chromeos.h
index 221f12c8..e3f086f3 100644
--- a/hardware_chromeos.h
+++ b/hardware_chromeos.h
@@ -46,6 +46,7 @@ class HardwareChromeOS final : public HardwareInterface {
bool CancelPowerwash() override;
bool GetNonVolatileDirectory(base::FilePath* path) const override;
bool GetPowerwashSafeDirectory(base::FilePath* path) const override;
+ int64_t GetBuildTimestamp() const override;
private:
DISALLOW_COPY_AND_ASSIGN(HardwareChromeOS);
diff --git a/metrics_utils.cc b/metrics_utils.cc
index 11260fc6..433ca1e7 100644
--- a/metrics_utils.cc
+++ b/metrics_utils.cc
@@ -74,6 +74,7 @@ metrics::AttemptResult GetAttemptResult(ErrorCode code) {
case ErrorCode::kDownloadPayloadVerificationError:
case ErrorCode::kSignedDeltaPayloadExpectedError:
case ErrorCode::kDownloadPayloadPubKeyVerificationError:
+ case ErrorCode::kPayloadTimestampError:
return metrics::AttemptResult::kPayloadVerificationFailed;
case ErrorCode::kNewRootfsVerificationError:
@@ -205,6 +206,7 @@ metrics::DownloadErrorCode GetDownloadErrorCode(ErrorCode code) {
case ErrorCode::kOmahaRequestXMLHasEntityDecl:
case ErrorCode::kFilesystemVerifierError:
case ErrorCode::kUserCanceled:
+ case ErrorCode::kPayloadTimestampError:
break;
// Special flags. These can't happen (we mask them out above) but
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index a1561327..b338d344 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -1502,6 +1502,14 @@ ErrorCode DeltaPerformer::ValidateManifest() {
}
}
+ if (manifest_.max_timestamp() < hardware_->GetBuildTimestamp()) {
+ LOG(ERROR) << "The current OS build timestamp ("
+ << hardware_->GetBuildTimestamp()
+ << ") is newer than the maximum timestamp in the manifest ("
+ << manifest_.max_timestamp() << ")";
+ return ErrorCode::kPayloadTimestampError;
+ }
+
// TODO(garnold) we should be adding more and more manifest checks, such as
// partition boundaries etc (see chromium-os:37661).
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index d1918b71..2ee4516d 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -638,6 +638,20 @@ TEST_F(DeltaPerformerTest, ValidateManifestBadMinorVersion) {
ErrorCode::kUnsupportedMinorPayloadVersion);
}
+TEST_F(DeltaPerformerTest, ValidateManifestDowngrade) {
+ // The Manifest we are validating.
+ DeltaArchiveManifest manifest;
+
+ manifest.set_minor_version(kFullPayloadMinorVersion);
+ manifest.set_max_timestamp(1);
+ fake_hardware_.SetBuildTimestamp(2);
+
+ RunManifestValidation(manifest,
+ DeltaPerformer::kSupportedMajorPayloadVersion,
+ InstallPayloadType::kFull,
+ ErrorCode::kPayloadTimestampError);
+}
+
TEST_F(DeltaPerformerTest, BrilloMetadataSignatureSizeTest) {
EXPECT_TRUE(performer_.Write(kDeltaMagic, sizeof(kDeltaMagic)));
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 0716c1f1..85785c55 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -322,6 +322,10 @@ int Main(int argc, char** argv) {
DEFINE_string(zlib_fingerprint, "",
"The fingerprint of zlib in the source image in hash string "
"format, used to check imgdiff compatibility.");
+ DEFINE_int64(max_timestamp,
+ 0,
+ "The maximum timestamp of the OS allowed to apply this "
+ "payload.");
DEFINE_string(old_channel, "",
"The channel for the old image. 'dev-channel', 'npo-channel', "
@@ -573,6 +577,8 @@ int Main(int argc, char** argv) {
}
}
+ payload_config.max_timestamp = FLAGS_max_timestamp;
+
if (payload_config.is_delta) {
LOG(INFO) << "Generating delta update";
} else {
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index 2f95b21c..d2ae7062 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -70,6 +70,7 @@ bool PayloadFile::Init(const PayloadGenerationConfig& config) {
*(manifest_.mutable_new_image_info()) = config.target.image_info;
manifest_.set_block_size(config.block_size);
+ manifest_.set_max_timestamp(config.max_timestamp);
return true;
}
diff --git a/payload_generator/payload_generation_config.h b/payload_generator/payload_generation_config.h
index 8617d14d..dd3242ac 100644
--- a/payload_generator/payload_generation_config.h
+++ b/payload_generator/payload_generation_config.h
@@ -190,6 +190,9 @@ struct PayloadGenerationConfig {
// The block size used for all the operations in the manifest.
size_t block_size = 4096;
+
+ // The maximum timestamp of the OS allowed to apply this payload.
+ int64_t max_timestamp = 0;
};
} // namespace chromeos_update_engine
diff --git a/payload_state.cc b/payload_state.cc
index 04b6579b..78594201 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -295,6 +295,7 @@ void PayloadState::UpdateFailed(ErrorCode error) {
case ErrorCode::kPayloadMismatchedType:
case ErrorCode::kUnsupportedMajorPayloadVersion:
case ErrorCode::kUnsupportedMinorPayloadVersion:
+ case ErrorCode::kPayloadTimestampError:
IncrementUrlIndex();
break;
diff --git a/scripts/brillo_update_payload b/scripts/brillo_update_payload
index 8d51118b..9b599d41 100755
--- a/scripts/brillo_update_payload
+++ b/scripts/brillo_update_payload
@@ -143,6 +143,10 @@ if [[ "${COMMAND}" == "generate" ]]; then
"Optional: Path to a source image. If specified, this makes a delta update."
DEFINE_string metadata_size_file "" \
"Optional: Path to output metadata size."
+ DEFINE_string max_timestamp "" \
+ "Optional: The maximum unix timestamp of the OS allowed to apply this \
+payload, should be set to a number higher than the build timestamp of the \
+system running on the device, 0 if not specified."
fi
if [[ "${COMMAND}" == "hash" || "${COMMAND}" == "sign" ]]; then
DEFINE_string unsigned_payload "" "Path to the input unsigned payload."
@@ -524,6 +528,10 @@ cmd_generate() {
GENERATOR_ARGS+=( --out_metadata_size_file="${FLAGS_metadata_size_file}" )
fi
+ if [[ -n "${FLAGS_max_timestamp}" ]]; then
+ GENERATOR_ARGS+=( --max_timestamp="${FLAGS_max_timestamp}" )
+ fi
+
if [[ -n "${POSTINSTALL_CONFIG_FILE}" ]]; then
GENERATOR_ARGS+=(
--new_postinstall_config_file="${POSTINSTALL_CONFIG_FILE}"
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 1269cefd..0fa1fa1b 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -26,6 +26,7 @@
#include <brillo/bind_lambda.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/strings/string_utils.h>
+#include <log/log.h>
#include "update_engine/common/constants.h"
#include "update_engine/common/file_fetcher.h"
@@ -308,6 +309,11 @@ void UpdateAttempterAndroid::ProcessingDone(const ActionProcessor* processor,
LOG(INFO) << "Resetting update progress.";
break;
+ case ErrorCode::kPayloadTimestampError:
+ // SafetyNet logging, b/36232423
+ android_errorWriteLog(0x534e4554, "36232423");
+ break;
+
default:
// Ignore all other error codes.
break;
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index aed2aaab..02ec19f3 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -76,6 +76,7 @@ bool HandleErrorCode(ErrorCode err_code, int* url_num_error_p) {
case ErrorCode::kPayloadMismatchedType:
case ErrorCode::kUnsupportedMajorPayloadVersion:
case ErrorCode::kUnsupportedMinorPayloadVersion:
+ case ErrorCode::kPayloadTimestampError:
LOG(INFO) << "Advancing download URL due to error "
<< chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
diff --git a/update_metadata.proto b/update_metadata.proto
index 454c7368..596a04ef 100644
--- a/update_metadata.proto
+++ b/update_metadata.proto
@@ -281,4 +281,8 @@ message DeltaArchiveManifest {
// array can have more than two partitions if needed, and they are identified
// by the partition name.
repeated PartitionUpdate partitions = 13;
+
+ // The maximum timestamp of the OS allowed to apply this payload.
+ // Can be used to prevent downgrading the OS.
+ optional int64 max_timestamp = 14;
}