From 5b5be651a405a02eaba457033e38b1965f1ae62f Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Mon, 18 Sep 2023 12:52:59 +0000 Subject: 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 --- cmds/installd/otapreopt.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp index a447cda492..822ab7fbb7 100644 --- a/cmds/installd/otapreopt.cpp +++ b/cmds/installd/otapreopt.cpp @@ -437,6 +437,9 @@ private: 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)) { -- cgit v1.2.3-59-g8ed1b