recovery: fixup `Add runtime checks for A/B vs traditional updates`

 * CheckPackageMetadata does more than just comparing the ota-type
   in metadata with an expected ota-type, so we should not be using
   it for determining the update is an A/B update.

 * Move the logic to compare ota-type out of CheckPackageMetadata
   and keep using the method to check for other stuff.

Change-Id: I531377c2bd64e588de451bdbfbf84c1c6e88d6c3
diff --git a/install/install.cpp b/install/install.cpp
index b836fac..d376433 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -183,19 +183,6 @@
 }
 
 int CheckPackageMetadata(const std::map<std::string, std::string>& metadata, OtaType ota_type) {
-  auto package_ota_type = get_value(metadata, "ota-type");
-  auto expected_ota_type = OtaTypeToString(ota_type);
-  if (ota_type != OtaType::AB && ota_type != OtaType::BRICK) {
-    LOG(INFO) << "Skip package metadata check for ota type " << expected_ota_type;
-    return 0;
-  }
-
-  if (package_ota_type != expected_ota_type) {
-    LOG(ERROR) << "Unexpected ota package type, expects " << expected_ota_type << ", actual "
-               << package_ota_type;
-    return INSTALL_ERROR;
-  }
-
   auto device = android::base::GetProperty("ro.product.device", "");
   auto pkg_device = get_value(metadata, "pre-device");
   if (pkg_device != device || pkg_device.empty()) {
@@ -331,7 +318,13 @@
   bool is_ab_ota = false;
   if (ReadMetadataFromPackage(zip, &metadata)) {
     ReadSourceTargetBuild(metadata, log_buffer);
-    if (CheckPackageMetadata(metadata, OtaType::AB) == 0) is_ab_ota = true;
+    if (get_value(metadata, "ota-type") == OtaTypeToString(OtaType::AB)) {
+        is_ab_ota = true;
+        int check_status = CheckPackageMetadata(metadata, OtaType::AB);
+        if (check_status != 0) {
+            return check_status;
+        }
+    }
   }
 
   // The updater in child process writes to the pipe to communicate with recovery.