Clear profile when switching between boot image profile and app profile
A profile is cleared only if its status is `kBadMagic`,
`kVersionMismatch`, or `kBadData`
(https://cs.android.com/android/platform/superproject/+/master:art/libprofile/profile/profile_compilation_info.cc;l=790-792;drc=486353b0ce7876c059f7f0caded6b0f3b9ecda98).
Before this change, when switching between boot image profile and app
profile, the profile cannot be cleared because its status was regarded
as kMergeError. This CL fixes the issue by changing the status to
kVersionMismatch.
Bug: 258486155
Test: -
1. adb shell setprop dalvik.vm.profilebootclasspath true
2. adb shell stop && adb shell start
3. adb shell killall -USR1 com.google.android.youtube
4. adb shell profman --dump-only --profile-file=/data/misc/profiles/cur/0/com.google.android.youtube/primary.prof
5. See the boot image profile being properly generated
Change-Id: I2bf5d3dcbc5a044907f83521545e18e11c167a25
diff --git a/libprofile/profile/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
index d6eb360..4970f0f 100644
--- a/libprofile/profile/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -1710,7 +1710,7 @@
if (memcmp(header.GetVersion(), version_, kProfileVersionSize) != 0) {
*error = IsForBootImage() ? "Expected boot profile, got app profile."
: "Expected app profile, got boot profile.";
- return ProfileLoadStatus::kMergeError;
+ return ProfileLoadStatus::kVersionMismatch;
}
// Check if there are too many section infos.