HardwareInterface::IsPartitionUpdateValid: fine grained error
Let the function emit an error code instead of a boolean to indicate
details of the error that is encountered.
For every partition, if downgrade is detected, emit
kPayloadTimestampError. In this case, still check other partitions for
more severe errors before returning this error.
In some cases, e.g. DeltaArchiveManifest carries a version field that is
not a recognized format, or timestamp sysprops in Android is not an
integer, report a more severe error.
If only downgrade errors are encountered, AllowDowngrade() can still
override the result, and proceed with the update; but, AllowDowngrade
cannot override those severe errors.
Test: update_engine_unittest
Bug: 162623577
Bug: 162553432
Change-Id: Ifc2a6fcd66239c755fb4f6528c3d8c6848afcb27
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index 0fffbfb..b37b007 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -25,6 +25,8 @@
#include <base/files/file_path.h>
#include <base/time/time.h>
+#include "update_engine/common/error_code.h"
+
namespace chromeos_update_engine {
// The hardware interface allows access to the crossystem exposed properties,
@@ -153,8 +155,15 @@
// version number of partition `partition_name`. The notion of
// "newer" is defined by this function. Caller should not make
// any assumption about the underlying logic.
- virtual bool IsPartitionUpdateValid(const std::string& partition_name,
- const std::string& new_version) const = 0;
+ // Return:
+ // - kSuccess if update is valid.
+ // - kPayloadTimestampError if downgrade is detected
+ // - kDownloadManifestParseError if |new_version| has an incorrect format
+ // - Other error values if the source of error is known, or kError for
+ // a generic error on the device.
+ virtual ErrorCode IsPartitionUpdateValid(
+ const std::string& partition_name,
+ const std::string& new_version) const = 0;
};
} // namespace chromeos_update_engine