Add maximum timestamp to the payload.
Added a new field max_timestamp in the protobuf, from now on
update_engine will reject any payload without this field.
If the OS build timestamp is newer than the max_timestamp, the payload
will also be rejected to prevent downgrade.
Bug: 36232423
Test: update_engine_unittests
Merged-In: Ib20f5f35aaf41165013bada02bc8720917358237
Change-Id: Ib20f5f35aaf41165013bada02bc8720917358237
diff --git a/hardware_android.cc b/hardware_android.cc
index 4c5473f..5e2ee11 100644
--- a/hardware_android.cc
+++ b/hardware_android.cc
@@ -54,6 +54,7 @@
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.
@@ -199,4 +200,8 @@
return false;
}
+int64_t HardwareAndroid::GetBuildTimestamp() const {
+ return property_get_int64(kPropBuildDateUTC, 0);
+}
+
} // namespace chromeos_update_engine