From 038a19ba97a7bce6e40597cbff70a2e22c3d3c13 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 9 Feb 2022 19:51:52 -0800 Subject: More robust app data and user data removal. 1. rename the folder, so any new files will end up in the renamed folder. this also greatly reduces chances that app will be able to create new files. 2. delete the renamed folder 3. provide an api to cleanup renamed/deleted folders on system startup Bug: 162757029 Test: atest installd_service_test installd_cache_test installd_utils_test installd_dexopt_test installd_otapreopt_test installd_file_test Change-Id: If1c209d49675f7fa9df60b6136588e3b0a7786e5 --- cmds/installd/InstalldNativeService.cpp | 34 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'cmds/installd/InstalldNativeService.cpp') diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index c3256fcfff..89d4868b09 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -968,13 +968,13 @@ binder::Status InstalldNativeService::destroyAppData(const std::optional& 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 -- cgit v1.2.3-59-g8ed1b