From 9d4b55b1b6a2e90a22e54b826eff2dcb1d18403c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Casta=C3=B1=C3=B3n?= Date: Wed, 27 Feb 2019 12:28:49 +0100 Subject: bootable: Read all asserts in case there are more than one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In A/B, the device check isn´t done by the updater script, but using metadata for it. Let´s search if the device codename/assert is included in the string. Change-Id: Ie856ac699aaa83de2b364bc85a510a037d36edf9 Signed-off-by: Hernán Castañón Signed-off-by: theimpulson --- install.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install.cpp b/install.cpp index 8e956c6c..db5792b8 100644 --- a/install.cpp +++ b/install.cpp @@ -143,9 +143,18 @@ static int check_newer_ab_build(ZipArchiveHandle zip) { } } + // We allow the package to carry multiple product names split by ","; + // e.g. pre-device=device1,device2,device3 ... We will fail the + // verification if the device's name doesn't match any of these carried names. std::string value = android::base::GetProperty("ro.product.device", ""); const std::string& pkg_device = metadata["pre-device"]; - if (pkg_device != value || pkg_device.empty()) { + bool product_name_match = false; + for (const std::string& name : android::base::Split(pkg_device, ",")) { + if (value == android::base::Trim(name)) { + product_name_match = true; + } + } + if (!product_name_match) { LOG(ERROR) << "Package is for product " << pkg_device << " but expected " << value; return INSTALL_ERROR; } -- cgit v1.2.3