bootable: read all asserts in case there are more than one.

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 <herna@paranoidandroid.co>
This commit is contained in:
Hernán Castañón
2019-02-27 12:28:49 +01:00
committed by bigbiff
parent 0864aa54ce
commit 990168bec0

View File

@@ -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<std::string> 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;
}