Improve profile merging error logging

Do not log an error if the profile version differs. This can happen
when switching boot image profiling on/off and can lead to unhelpful
logs.

Test: profile tests
Bug: 139884006
Change-Id: I4cef4accb786041338aa8c8b82892b70a02a4e03
diff --git a/profman/profile_assistant.cc b/profman/profile_assistant.cc
index 531bb27..7107944 100644
--- a/profman/profile_assistant.cc
+++ b/profman/profile_assistant.cc
@@ -60,9 +60,20 @@
       LOG(WARNING) << "Could not load profile file at index " << i;
       return kErrorBadProfiles;
     }
-    if (options.IsBootImageMerge() != cur_info.IsForBootImage()) {
-      // The app profile was not configured for boot image merging. Ignore.
-      continue;
+
+    // Check version mismatch.
+    // This may happen during profile analysis if one profile is regular and
+    // the other one is for the boot image. For example when switching on-off
+    // the boot image profiles.
+    if (!info.SameVersion(cur_info)) {
+      if (options.IsForceMerge()) {
+        // If we have to merge forcefully, ignore the current profile and
+        // continue to the next one.
+        continue;
+      } else {
+        // Otherwise, return an error.
+        return kErrorDifferentVersions;
+      }
     }
 
     if (!info.MergeWith(cur_info)) {