From 29591736958a7ed45f4b5982ca9a46756baa0f6d Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 20 Nov 2017 17:46:19 -0800 Subject: Add snapshotProfile APIs to installd Add APIs that will snapshot the profile information of packages in a well known location. The snapshot ownership is given to AID_SYSTEM. The location is next to the application reference profile: /data/misc/profiles/ref/pkg_name/primary.prof.snapshot. The intended flow for snapshotting profiles is: mInstaller.snapshotProfile(appId, packageName, codePath); // open profile snapshot mInstaller.destroyProfileSnapshot(packageName, codePath); The reference profile directory is made searchable by others (in order for the system to be able to open the snapshot profile). Test: installd_dexopt_test installd_utils_test Bug: 30934496 Change-Id: Ic4973d5c67243d7724ecd24a238ed0ae8baadcc6 --- cmds/installd/utils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cmds/installd/utils.cpp') diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index 7dca7c6422..61c9c8ff08 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -236,6 +236,7 @@ std::string create_data_dalvik_cache_path() { const std::string PROFILE_EXT = ".prof"; const std::string CURRENT_PROFILE_EXT = ".cur"; const std::string PRIMARY_PROFILE_NAME = "primary" + PROFILE_EXT; +const std::string SNAPSHOT_PROFILE_EXT = ".snapshot"; // Gets the parent directory and the file name for the given secondary dex path. // Returns true on success, false on failure (if the dex_path does not have the expected @@ -289,6 +290,14 @@ std::string create_reference_profile_path(const std::string& location, bool is_s } } +std::string create_snapshot_profile_path(const std::string& package, + const std::string& code_path ATTRIBUTE_UNUSED) { + // TODD(calin): code_path is ignored for now. It will be used when each split gets its own + // profile file. + std::string ref_profile = create_reference_profile_path(package, /*is_secondary_dex*/ false); + return ref_profile + SNAPSHOT_PROFILE_EXT; +} + std::vector get_known_users(const char* volume_uuid) { std::vector users; -- cgit v1.2.3-59-g8ed1b