From e1ae78cd547d68192df7803a86bbffee6ed52703 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 26 Jun 2020 11:06:00 -0400 Subject: Add recovery support of dynamic fingerprints After http://go/aog/1306461, the metadata in the OTA package can have multiple fingerprints or device names e.g. from pre-device=lmiin to pre-device=lmiin|lmiinpro This CL updates recovery code to recognize them Test: Added unit tests for this Bug: 159850736 Change-Id: If6315bf2d3dea77abb9d7d83145f55b0148cdfb1 --- tests/unit/install_test.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp index ee753494c..90c4b1409 100644 --- a/tests/unit/install_test.cpp +++ b/tests/unit/install_test.cpp @@ -466,6 +466,34 @@ TEST(InstallTest, CheckPackageMetadata_ab_fingerprint) { TestCheckPackageMetadata(metadata, OtaType::AB, false); } +TEST(InstallTest, CheckPackageMetadata_dynamic_fingerprint) { + std::string device = android::base::GetProperty("ro.product.device", ""); + ASSERT_FALSE(device.empty()); + + std::string finger_print = android::base::GetProperty("ro.build.fingerprint", ""); + ASSERT_FALSE(finger_print.empty()); + + std::string metadata = android::base::Join( + std::vector{ + "ota-type=AB", + "pre-device=please|work|" + device + "|please|work", + "pre-build=" + finger_print = "pass|this|test", + "post-timestamp=" + std::to_string(std::numeric_limits::max()), + }, + "\n"); + TestCheckPackageMetadata(metadata, OtaType::AB, true); + + metadata = android::base::Join( + std::vector{ + "ota-type=AB", + "pre-device=" + device, + "pre-build=dummy_build_fingerprint", + "post-timestamp=" + std::to_string(std::numeric_limits::max()), + }, + "\n"); + TestCheckPackageMetadata(metadata, OtaType::AB, false); +} + TEST(InstallTest, CheckPackageMetadata_ab_post_timestamp) { std::string device = android::base::GetProperty("ro.product.device", ""); ASSERT_NE("", device); -- cgit v1.2.3