Per user, per storage type cleanup to match PM behavior.
Bug: 162757029
Test: atest installd_service_test installd_cache_test installd_utils_test installd_dexopt_test installd_otapreopt_test installd_file_test
Change-Id: I7941396fb2120f6636601e45b71490d86d2c4831
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 5051132..953847e 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -3176,16 +3176,20 @@
return ok();
}
-binder::Status InstalldNativeService::cleanupDeletedDirs(const std::optional<std::string>& uuid) {
+binder::Status InstalldNativeService::cleanupInvalidPackageDirs(
+ const std::optional<std::string>& uuid, int32_t userId, int32_t flags) {
const char* uuid_cstr = uuid ? uuid->c_str() : nullptr;
- const auto users = get_known_users(uuid_cstr);
- for (auto userId : users) {
- auto ce_path = create_data_user_ce_path(uuid_cstr, userId);
- auto de_path = create_data_user_de_path(uuid_cstr, userId);
- find_and_delete_renamed_deleted_dirs_under_path(ce_path);
- find_and_delete_renamed_deleted_dirs_under_path(de_path);
+ if (flags & FLAG_STORAGE_CE) {
+ auto ce_path = create_data_user_ce_path(uuid_cstr, userId);
+ cleanup_invalid_package_dirs_under_path(ce_path);
}
+
+ if (flags & FLAG_STORAGE_DE) {
+ auto de_path = create_data_user_de_path(uuid_cstr, userId);
+ cleanup_invalid_package_dirs_under_path(de_path);
+ }
+
return ok();
}