diff options
| author | 2022-02-14 20:33:42 +0000 | |
|---|---|---|
| committer | 2022-02-14 20:33:42 +0000 | |
| commit | b6c7a01c17a5c3dceceed6c6793b0161b87e50f9 (patch) | |
| tree | 022e36e137f696417ae290ec93fa8ead937be17c /cmds/installd/InstalldNativeService.cpp | |
| parent | 79bb2dc17584347412536f8faa11413b777f5a21 (diff) | |
| parent | fca40a5e0cef93cff0ccc4190109d882f6932a7e (diff) | |
Merge "More robust app data and user data removal." am: 0a258b89c7 am: cccc28a1b1 am: fca40a5e0c
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1983127
Change-Id: I0b1e02e59d68a2f9505eaa38ff4d9edace5f3734
Diffstat (limited to 'cmds/installd/InstalldNativeService.cpp')
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 4ce48d5715..c23396c7f2 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -957,13 +957,13 @@ binder::Status InstalldNativeService::destroyAppData(const std::optional<std::st binder::Status res = ok(); if (flags & FLAG_STORAGE_CE) { auto path = create_data_user_ce_package_path(uuid_, userId, pkgname, ceDataInode); - if (delete_dir_contents_and_dir(path) != 0) { + if (rename_delete_dir_contents_and_dir(path) != 0) { res = error("Failed to delete " + path); } } if (flags & FLAG_STORAGE_DE) { auto path = create_data_user_de_package_path(uuid_, userId, pkgname); - if (delete_dir_contents_and_dir(path) != 0) { + if (rename_delete_dir_contents_and_dir(path) != 0) { res = error("Failed to delete " + path); } if ((flags & FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES) == 0) { @@ -994,16 +994,15 @@ binder::Status InstalldNativeService::destroyAppData(const std::optional<std::st } auto path = StringPrintf("%s/Android/data/%s", extPath.c_str(), pkgname); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete contents of " + path); } - path = StringPrintf("%s/Android/media/%s", extPath.c_str(), pkgname); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete contents of " + path); } path = StringPrintf("%s/Android/obb/%s", extPath.c_str(), pkgname); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete contents of " + path); } } @@ -1551,27 +1550,27 @@ binder::Status InstalldNativeService::destroyUserData(const std::optional<std::s binder::Status res = ok(); if (flags & FLAG_STORAGE_DE) { auto path = create_data_user_de_path(uuid_, userId); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete " + path); } if (uuid_ == nullptr) { path = create_data_misc_legacy_path(userId); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete " + path); } path = create_primary_cur_profile_dir_path(userId); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete " + path); } } } if (flags & FLAG_STORAGE_CE) { auto path = create_data_user_ce_path(uuid_, userId); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete " + path); } path = findDataMediaPath(uuid, userId); - if (delete_dir_contents_and_dir(path, true) != 0) { + if (rename_delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete " + path); } } @@ -3190,5 +3189,18 @@ binder::Status InstalldNativeService::migrateLegacyObbData() { return ok(); } +binder::Status InstalldNativeService::cleanupDeletedDirs(const std::optional<std::string>& uuid) { + 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); + } + return ok(); +} + } // namespace installd } // namespace android |