From b911bc6afc6872e4c9a8d5c7c9c56c1b44644ed2 Mon Sep 17 00:00:00 2001 From: Samiul Islam Date: Fri, 14 Jan 2022 16:24:48 +0000 Subject: Create supplemental data directories when app data is created Supplemental data is closely related to app data, as such we want their creation to happen at the same time. Owner of the these data will be the supplemental process instead of the app. The root directory for supplemental data is /data/misc_{ce,de}//supplemental. This directory will be created by vold when user is created. Installd is responsible for creating app level directories under the root, e.g, /data/misc_ce/0/supplemental/. We also need code level directory under the app direcotory, but that will be done with a separate API. CreateAppData is responsible for things at app level, so we will be maintaining the same level of abstraction. Instlld will also create the shared directory under the app-level directory, e.g, /data/misc_ce/0/supplemental//shared and `cache` and `code_cache` directory under the `shared` directory. Supplemental data should be removed when app data is removed. This will be done in follow up Cls too. Some of the public APIs of installd service was not being used by anybody else, so made them private. Bug: 211763739 Bug: 217543371 Test: atest installd_service_test:AppSupplementalDataTest Ignore-AOSP-First: Feature is being developed in internal branch Change-Id: I966c76b032821610293c53ba875e2800a5ce4804 Merged-In: I966c76b032821610293c53ba875e2800a5ce4804 (cherry picked from commit c40dff533dd842bf6fae21c05eea472be7106ba2) --- cmds/installd/utils.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'cmds/installd/utils.cpp') diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index f04ee337d9..6650b761e1 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -197,6 +197,43 @@ std::string create_data_user_de_path(const char* volume_uuid, userid_t userid) { return StringPrintf("%s/user_de/%u", data.c_str(), userid); } +/** + * Create the path name where supplemental data for all apps will be stored. + * E.g. /data/misc_ce/0/supplemental + */ +std::string create_data_misc_supplemental_path(const char* uuid, bool isCeData, userid_t user) { + std::string data(create_data_path(uuid)); + if (isCeData) { + return StringPrintf("%s/misc_ce/%d/supplemental", data.c_str(), user); + } else { + return StringPrintf("%s/misc_de/%d/supplemental", data.c_str(), user); + } +} + +/** + * Create the path name where code data for all codes in a particular app will be stored. + * E.g. /data/misc_ce/0/supplemental/ + */ +std::string create_data_misc_supplemental_package_path(const char* volume_uuid, bool isCeData, + userid_t user, const char* package_name) { + check_package_name(package_name); + return StringPrintf("%s/%s", + create_data_misc_supplemental_path(volume_uuid, isCeData, user).c_str(), + package_name); +} + +/** + * Create the path name where shared code data for a particular app will be stored. + * E.g. /data/misc_ce/0/supplemental//shared + */ +std::string create_data_misc_supplemental_shared_path(const char* volume_uuid, bool isCeData, + userid_t user, const char* package_name) { + return StringPrintf("%s/shared", + create_data_misc_supplemental_package_path(volume_uuid, isCeData, user, + package_name) + .c_str()); +} + std::string create_data_misc_ce_rollback_base_path(const char* volume_uuid, userid_t user) { return StringPrintf("%s/misc_ce/%u/rollback", create_data_path(volume_uuid).c_str(), user); } -- cgit v1.2.3-59-g8ed1b