Add a method to installd to delete a reference profile.
The current use case of this method is cleaning up a temp reference
profile that PackageDexOptimizer creates.
Bug: 226318301
Test: atest CtsCompilationTestCases:AdbRootDependentCompilationTest#testCompile_usedByOtherApps
Ignore-AOSP-First: Merge conflicts.
Change-Id: I07bae8736455e169cbb09b01e3540f09fe4105bc
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index c104fea..4e12579 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1176,6 +1176,25 @@
return res;
}
+binder::Status InstalldNativeService::deleteReferenceProfile(const std::string& packageName,
+ const std::string& profileName) {
+ ENFORCE_UID(AID_SYSTEM);
+ CHECK_ARGUMENT_PACKAGE_NAME(packageName);
+ LOCK_PACKAGE();
+
+ // This function only supports primary dex'es.
+ std::string path =
+ create_reference_profile_path(packageName, profileName, /*is_secondary_dex=*/false);
+ if (unlink(path.c_str()) != 0) {
+ if (errno == ENOENT) {
+ return ok();
+ } else {
+ return error("Failed to delete profile " + profileName + " for " + packageName);
+ }
+ }
+ return ok();
+}
+
binder::Status InstalldNativeService::destroyAppData(const std::optional<std::string>& uuid,
const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode) {
ENFORCE_UID(AID_SYSTEM);