Don't clear profile on otapreopt.
`maybe_open_reference_profile` installs a hook that clears the profile
on destruction. This behavior is not expected. Fortunately, the cleanup
is blocked by a permission check, so it doesn't cause any damage.
However, it should not be attempted in the first place.
Bug: 300941544
Test: Run system/update_engine/scripts/update_device.py and see no more
"Permission denied" error.
Change-Id: I4d98d33a305de2487669ae3d7d69bbc4b9f2615b
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index a447cda..822ab7f 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -437,6 +437,9 @@
maybe_open_reference_profile(parameters_.pkgName, parameters_.apk_path,
parameters_.profile_name, profile_guided,
is_public, parameters_.uid, is_secondary_dex);
+ // `maybe_open_reference_profile` installs a hook that clears the profile on
+ // destruction. Disable it.
+ reference_profile.DisableCleanup();
struct stat sbuf;
if (reference_profile.fd() == -1 ||
(fstat(reference_profile.fd(), &sbuf) != -1 && sbuf.st_size == 0)) {