Move the package directory before deleting it.
This change avoids the race between installd and artd.
Bug: 261431149
Test: -
1. Add a "sleep" before artd creating the files.
2. Add a "sleep" before installd moving the dir and deleting the dir.
3. Install an app.
4. Run "pm compile" on the app.
5. While "pm compile" is on "sleep", uninstall the app.
6. See the compilation failed and the failure handled properly.
7. See the uninstallation succeeded and the package dir no longer
present.
Test: -
1. Add a "sleep" between artd invoking dex2oat and moving the files.
2. Do step 2-5 above.
3. See the same results.
Ignore-AOSP-First: ART Services
Change-Id: I4583943aeeb03915f76a5d66f44eff7347f8db14
diff --git a/cmds/installd/utils_default.cpp b/cmds/installd/utils_default.cpp
index a6025e6..85ce450 100644
--- a/cmds/installd/utils_default.cpp
+++ b/cmds/installd/utils_default.cpp
@@ -23,7 +23,7 @@
// platform dependent logic.
int rm_package_dir(const std::string& package_dir) {
- return delete_dir_contents_and_dir(package_dir);
+ return rename_delete_dir_contents_and_dir(package_dir);
}
} // namespace installd