Loading cmds/installd/commands.cpp +47 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <errno.h> #include <inttypes.h> #include <regex> #include <stdlib.h> #include <sys/capability.h> #include <sys/file.h> Loading Loading @@ -58,6 +59,26 @@ namespace installd { static constexpr const char* kCpPath = "/system/bin/cp"; static constexpr const char* kXattrDefault = "user.default"; static constexpr const char* PKG_LIB_POSTFIX = "/lib"; static constexpr const char* CACHE_DIR_POSTFIX = "/cache"; static constexpr const char* CODE_CACHE_DIR_POSTFIX = "/code_cache"; static constexpr const char* IDMAP_PREFIX = "/data/resource-cache/"; static constexpr const char* IDMAP_SUFFIX = "@idmap"; // NOTE: keep in sync with StorageManager static constexpr int FLAG_STORAGE_DE = 1 << 0; static constexpr int FLAG_STORAGE_CE = 1 << 1; // NOTE: keep in sync with Installer static constexpr int FLAG_CLEAR_CACHE_ONLY = 1 << 8; static constexpr int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9; /* dexopt needed flags matching those in dalvik.system.DexFile */ static constexpr int DEXOPT_DEX2OAT_NEEDED = 1; static constexpr int DEXOPT_PATCHOAT_NEEDED = 2; static constexpr int DEXOPT_SELF_PATCHOAT_NEEDED = 3; #define MIN_RESTRICTED_HOME_SDK_VERSION 24 // > M typedef int fd_t; Loading Loading @@ -1427,7 +1448,7 @@ static const char* parse_null(const char* arg) { } } int dexopt(const char* params[DEXOPT_PARAM_COUNT]) { int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) { return dexopt(params[0], // apk_path atoi(params[1]), // uid params[2], // pkgname Loading Loading @@ -2093,6 +2114,26 @@ int move_ab(const char* apk_path, const char* instruction_set, const char* oat_d LOG(ERROR) << "Cannot move_ab with null input"; return -1; } // Get the current slot suffix. No suffix, no A/B. std::string slot_suffix; { char buf[kPropertyValueMax]; if (get_property("ro.boot.slot_suffix", buf, nullptr) <= 0) { return -1; } slot_suffix = buf; // Validate. std::regex slot_suffix_regex("[a-zA-Z0-9_]+"); std::smatch slot_suffix_match; if (!std::regex_match(slot_suffix, slot_suffix_match, slot_suffix_regex)) { LOG(ERROR) << "Target slot suffix not legal: " << slot_suffix; return -1; } } // Validate other inputs. if (validate_apk_path(apk_path) != 0) { LOG(ERROR) << "invalid apk_path " << apk_path; return -1; Loading @@ -2108,9 +2149,11 @@ int move_ab(const char* apk_path, const char* instruction_set, const char* oat_d } const std::string a_image_path = create_image_filename(a_path); // B path = A path + ".b" const std::string b_path = StringPrintf("%s.b", a_path); const std::string b_image_path = StringPrintf("%s.b", a_image_path.c_str()); // B path = A path + slot suffix. const std::string b_path = StringPrintf("%s.%s", a_path, slot_suffix.c_str()); const std::string b_image_path = StringPrintf("%s.%s", a_image_path.c_str(), slot_suffix.c_str()); bool oat_success = move_ab_path(b_path, a_path); bool success; Loading cmds/installd/commands.h +3 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ namespace android { namespace installd { static constexpr size_t DEXOPT_PARAM_COUNT = 10U; int create_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags, appid_t appid, const char* seinfo, int target_sdk_version); int restorecon_app_data(const char* uuid, const char* pkgName, userid_t userid, int flags, Loading Loading @@ -69,7 +71,7 @@ int dexopt(const char *apk_path, static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size"); // Helper for the above, converting arguments. int dexopt(const char* params[DEXOPT_PARAM_COUNT]); int dexopt(const char* const params[DEXOPT_PARAM_COUNT]); int mark_boot_complete(const char *instruction_set); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); Loading cmds/installd/globals.cpp +18 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,22 @@ namespace android { namespace installd { static constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA static constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA static constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under // ANDROID_DATA static constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA static constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory under ANDROID_DATA static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under // ANDROID_DATA /* Directory records that are used in execution of commands. */ dir_rec_t android_app_dir; dir_rec_t android_app_ephemeral_dir; Loading Loading @@ -77,7 +93,7 @@ bool init_globals_from_data_and_root(const char* data, const char* root) { // Get the android ephemeral app directory. if (copy_and_append(&android_app_ephemeral_dir, &android_data_dir, EPHEMERAL_APP_SUBDIR) < 0) { return -1; return false; } // Get the android app native library directory. Loading @@ -86,7 +102,7 @@ bool init_globals_from_data_and_root(const char* data, const char* root) { } // Get the sd-card ASEC mount point. if (get_path_from_env(&android_asec_dir, "ASEC_MOUNTPOINT") < 0) { if (get_path_from_env(&android_asec_dir, ASEC_MOUNTPOINT_ENV_NAME) < 0) { return false; } Loading cmds/installd/globals.h +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,11 @@ namespace android { namespace installd { /* constants */ // Name of the environment variable that contains the asec mountpoint. static constexpr const char* ASEC_MOUNTPOINT_ENV_NAME = "ASEC_MOUNTPOINT"; /* data structures */ struct dir_rec_t { Loading cmds/installd/installd.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -557,7 +557,7 @@ done: return 0; } bool initialize_globals() { static bool initialize_globals() { const char* data_path = getenv("ANDROID_DATA"); if (data_path == nullptr) { ALOGE("Could not find ANDROID_DATA"); Loading Loading
cmds/installd/commands.cpp +47 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <errno.h> #include <inttypes.h> #include <regex> #include <stdlib.h> #include <sys/capability.h> #include <sys/file.h> Loading Loading @@ -58,6 +59,26 @@ namespace installd { static constexpr const char* kCpPath = "/system/bin/cp"; static constexpr const char* kXattrDefault = "user.default"; static constexpr const char* PKG_LIB_POSTFIX = "/lib"; static constexpr const char* CACHE_DIR_POSTFIX = "/cache"; static constexpr const char* CODE_CACHE_DIR_POSTFIX = "/code_cache"; static constexpr const char* IDMAP_PREFIX = "/data/resource-cache/"; static constexpr const char* IDMAP_SUFFIX = "@idmap"; // NOTE: keep in sync with StorageManager static constexpr int FLAG_STORAGE_DE = 1 << 0; static constexpr int FLAG_STORAGE_CE = 1 << 1; // NOTE: keep in sync with Installer static constexpr int FLAG_CLEAR_CACHE_ONLY = 1 << 8; static constexpr int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9; /* dexopt needed flags matching those in dalvik.system.DexFile */ static constexpr int DEXOPT_DEX2OAT_NEEDED = 1; static constexpr int DEXOPT_PATCHOAT_NEEDED = 2; static constexpr int DEXOPT_SELF_PATCHOAT_NEEDED = 3; #define MIN_RESTRICTED_HOME_SDK_VERSION 24 // > M typedef int fd_t; Loading Loading @@ -1427,7 +1448,7 @@ static const char* parse_null(const char* arg) { } } int dexopt(const char* params[DEXOPT_PARAM_COUNT]) { int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) { return dexopt(params[0], // apk_path atoi(params[1]), // uid params[2], // pkgname Loading Loading @@ -2093,6 +2114,26 @@ int move_ab(const char* apk_path, const char* instruction_set, const char* oat_d LOG(ERROR) << "Cannot move_ab with null input"; return -1; } // Get the current slot suffix. No suffix, no A/B. std::string slot_suffix; { char buf[kPropertyValueMax]; if (get_property("ro.boot.slot_suffix", buf, nullptr) <= 0) { return -1; } slot_suffix = buf; // Validate. std::regex slot_suffix_regex("[a-zA-Z0-9_]+"); std::smatch slot_suffix_match; if (!std::regex_match(slot_suffix, slot_suffix_match, slot_suffix_regex)) { LOG(ERROR) << "Target slot suffix not legal: " << slot_suffix; return -1; } } // Validate other inputs. if (validate_apk_path(apk_path) != 0) { LOG(ERROR) << "invalid apk_path " << apk_path; return -1; Loading @@ -2108,9 +2149,11 @@ int move_ab(const char* apk_path, const char* instruction_set, const char* oat_d } const std::string a_image_path = create_image_filename(a_path); // B path = A path + ".b" const std::string b_path = StringPrintf("%s.b", a_path); const std::string b_image_path = StringPrintf("%s.b", a_image_path.c_str()); // B path = A path + slot suffix. const std::string b_path = StringPrintf("%s.%s", a_path, slot_suffix.c_str()); const std::string b_image_path = StringPrintf("%s.%s", a_image_path.c_str(), slot_suffix.c_str()); bool oat_success = move_ab_path(b_path, a_path); bool success; Loading
cmds/installd/commands.h +3 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ namespace android { namespace installd { static constexpr size_t DEXOPT_PARAM_COUNT = 10U; int create_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags, appid_t appid, const char* seinfo, int target_sdk_version); int restorecon_app_data(const char* uuid, const char* pkgName, userid_t userid, int flags, Loading Loading @@ -69,7 +71,7 @@ int dexopt(const char *apk_path, static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size"); // Helper for the above, converting arguments. int dexopt(const char* params[DEXOPT_PARAM_COUNT]); int dexopt(const char* const params[DEXOPT_PARAM_COUNT]); int mark_boot_complete(const char *instruction_set); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); Loading
cmds/installd/globals.cpp +18 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,22 @@ namespace android { namespace installd { static constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA static constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA static constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under // ANDROID_DATA static constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA static constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory under ANDROID_DATA static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under // ANDROID_DATA /* Directory records that are used in execution of commands. */ dir_rec_t android_app_dir; dir_rec_t android_app_ephemeral_dir; Loading Loading @@ -77,7 +93,7 @@ bool init_globals_from_data_and_root(const char* data, const char* root) { // Get the android ephemeral app directory. if (copy_and_append(&android_app_ephemeral_dir, &android_data_dir, EPHEMERAL_APP_SUBDIR) < 0) { return -1; return false; } // Get the android app native library directory. Loading @@ -86,7 +102,7 @@ bool init_globals_from_data_and_root(const char* data, const char* root) { } // Get the sd-card ASEC mount point. if (get_path_from_env(&android_asec_dir, "ASEC_MOUNTPOINT") < 0) { if (get_path_from_env(&android_asec_dir, ASEC_MOUNTPOINT_ENV_NAME) < 0) { return false; } Loading
cmds/installd/globals.h +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,11 @@ namespace android { namespace installd { /* constants */ // Name of the environment variable that contains the asec mountpoint. static constexpr const char* ASEC_MOUNTPOINT_ENV_NAME = "ASEC_MOUNTPOINT"; /* data structures */ struct dir_rec_t { Loading
cmds/installd/installd.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -557,7 +557,7 @@ done: return 0; } bool initialize_globals() { static bool initialize_globals() { const char* data_path = getenv("ANDROID_DATA"); if (data_path == nullptr) { ALOGE("Could not find ANDROID_DATA"); Loading