From 990168bec01ec9685ad9581b023dbf39f3068d52 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: [PATCH] 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 --- installcommand.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/installcommand.cpp b/installcommand.cpp index 99f4c535..fa079ea2 100644 --- a/installcommand.cpp +++ b/installcommand.cpp @@ -124,9 +124,23 @@ static int check_newer_ab_build(ZipWrap* zip) property_get("ro.product.device", value, ""); const std::string& pkg_device = metadata["pre-device"]; - if (pkg_device != value || pkg_device.empty()) { + + std::vector assertResults = android::base::Split(pkg_device, ","); + + bool deviceExists = false; + + for(const std::string& deviceAssert : assertResults) + { + std::string assertName = android::base::Trim(deviceAssert); + if (assertName == value && !assertName.empty()) { + deviceExists = true; + break; + } + } + + if (!deviceExists) { printf("Package is for product %s but expected %s\n", - pkg_device.c_str(), value); + pkg_device.c_str(), value); return INSTALL_ERROR; }