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>
diff --git a/installcommand.cpp b/installcommand.cpp
index 99f4c53..fa079ea 100644
--- a/installcommand.cpp
+++ b/installcommand.cpp
@@ -124,9 +124,23 @@
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;
}