to install/installcommand.cpp

Change-Id: I96384bbc92b202a8a5561229488052d488ca6bc1
This commit is contained in:
mauronofrio
2020-05-18 16:08:12 -04:00
committed by bigbiff
parent 8a45a1883c
commit c79f86ef94
2 changed files with 20 additions and 337 deletions

View File

@@ -121,12 +121,30 @@ static int check_newer_ab_build(ZipWrap* zip)
}
}
char value[PROPERTY_VALUE_MAX];
char propmodel[PROPERTY_VALUE_MAX];
char propname[PROPERTY_VALUE_MAX];
property_get("ro.product.device", value, "");
property_get("ro.product.model", propmodel, "");
property_get("ro.product.name", propname, "");
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 == propmodel || assertName == propname ) && !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;
}