Loading cmds/installd/commands.cpp +22 −0 Original line number Original line Diff line number Diff line Loading @@ -1385,6 +1385,28 @@ bool merge_profiles(uid_t uid, const char *pkgname) { return analyse_profiles(uid, pkgname); return analyse_profiles(uid, pkgname); } } static const char* parse_null(const char* arg) { if (strcmp(arg, "!") == 0) { return nullptr; } else { return arg; } } int dexopt(const char* params[DEXOPT_PARAM_COUNT]) { return dexopt(params[0], // apk_path atoi(params[1]), // uid params[2], // pkgname params[3], // instruction_set atoi(params[4]), // dexopt_needed params[5], // oat_dir atoi(params[6]), // dexopt_flags params[7], // compiler_filter parse_null(params[8]), // volume_uuid parse_null(params[9])); // shared_libraries static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param count"); } int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set, int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries) const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries) Loading cmds/installd/commands.h +15 −3 Original line number Original line Diff line number Diff line Loading @@ -56,9 +56,21 @@ bool merge_profiles(uid_t uid, const char *pkgname); bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files); bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files); int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set, int dexopt(const char *apk_path, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, uid_t uid, const char* volume_uuid, const char* shared_libraries); const char *pkgName, const char *instruction_set, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, const char* volume_uuid, const char* shared_libraries); 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 mark_boot_complete(const char *instruction_set); int mark_boot_complete(const char *instruction_set); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); int idmap(const char *target_path, const char *overlay_path, uid_t uid); int idmap(const char *target_path, const char *overlay_path, uid_t uid); Loading cmds/installd/installd.cpp +28 −17 Original line number Original line Diff line number Diff line Loading @@ -219,7 +219,8 @@ static int do_destroy_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSE // We use otapreopt_chroot to get into the chroot. // We use otapreopt_chroot to get into the chroot. static constexpr const char* kOtaPreopt = "/system/bin/otapreopt_chroot"; static constexpr const char* kOtaPreopt = "/system/bin/otapreopt_chroot"; static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { static int do_ota_dexopt(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { // Time to fork and run otapreopt. // Time to fork and run otapreopt. // Check that the tool exists. // Check that the tool exists. Loading @@ -231,12 +232,14 @@ static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { pid_t pid = fork(); pid_t pid = fork(); if (pid == 0) { if (pid == 0) { const char* argv[1 + 9 + 1]; const char* argv[1 + DEXOPT_PARAM_COUNT + 1]; argv[0] = kOtaPreopt; argv[0] = kOtaPreopt; for (size_t i = 1; i <= 9; ++i) { argv[i] = arg[i - 1]; for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) { argv[i + 1] = args[i]; } } argv[10] = nullptr; argv[DEXOPT_PARAM_COUNT + 1] = nullptr; execv(argv[0], (char * const *)argv); execv(argv[0], (char * const *)argv); PLOG(ERROR) << "execv(OTAPREOPT_CHROOT) failed"; PLOG(ERROR) << "execv(OTAPREOPT_CHROOT) failed"; Loading @@ -252,22 +255,30 @@ static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { } } } } static int do_regular_dexopt(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { return dexopt(args); } using DexoptFn = int (*)(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX]); static int do_dexopt(char **arg, char reply[REPLY_MAX]) static int do_dexopt(char **arg, char reply[REPLY_MAX]) { { const char* args[DEXOPT_PARAM_COUNT]; for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) { CHECK(arg[i] != nullptr); args[i] = arg[i]; } int dexopt_flags = atoi(arg[6]); int dexopt_flags = atoi(arg[6]); DexoptFn dexopt_fn; if ((dexopt_flags & DEXOPT_OTA) != 0) { if ((dexopt_flags & DEXOPT_OTA) != 0) { return do_ota_dexopt(arg, reply); dexopt_fn = do_ota_dexopt; } } else { return dexopt(arg[0], // apk_path dexopt_fn = do_regular_dexopt; atoi(arg[1]), // uid } arg[2], // pkgname return dexopt_fn(args, reply); arg[3], // instruction_set atoi(arg[4]), // dexopt_needed arg[5], // oat_dir dexopt_flags, arg[7], // compiler_filter parse_null(arg[8]), // volume_uuid parse_null(arg[9])); // shared_libraries } } static int do_merge_profiles(char **arg, char reply[REPLY_MAX]) static int do_merge_profiles(char **arg, char reply[REPLY_MAX]) Loading cmds/installd/installd_constants.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ namespace android { namespace android { namespace installd { namespace installd { constexpr size_t DEXOPT_PARAM_COUNT = 10U; /* elements combined with a valid package name to form paths */ /* elements combined with a valid package name to form paths */ constexpr const char* PRIMARY_USER_PREFIX = "data/"; constexpr const char* PRIMARY_USER_PREFIX = "data/"; Loading cmds/installd/otapreopt.cpp +6 −14 Original line number Original line Diff line number Diff line Loading @@ -188,12 +188,14 @@ private: bool ReadPackage(int argc ATTRIBUTE_UNUSED, char** argv) { bool ReadPackage(int argc ATTRIBUTE_UNUSED, char** argv) { size_t index = 0; size_t index = 0; while (index < ARRAY_SIZE(package_parameters_) && static_assert(DEXOPT_PARAM_COUNT == ARRAY_SIZE(package_parameters_), "Unexpected dexopt param count"); while (index < DEXOPT_PARAM_COUNT && argv[index + 1] != nullptr) { argv[index + 1] != nullptr) { package_parameters_[index] = argv[index + 1]; package_parameters_[index] = argv[index + 1]; index++; index++; } } if (index != ARRAY_SIZE(package_parameters_)) { if (index != ARRAY_SIZE(package_parameters_) || argv[index + 1] != nullptr) { LOG(ERROR) << "Wrong number of parameters"; LOG(ERROR) << "Wrong number of parameters"; return false; return false; } } Loading Loading @@ -357,17 +359,7 @@ private: } } int RunPreopt() { int RunPreopt() { int ret = dexopt(package_parameters_[0], // apk_path return dexopt(package_parameters_); atoi(package_parameters_[1]), // uid package_parameters_[2], // pkgname package_parameters_[3], // instruction_set atoi(package_parameters_[4]), // dexopt_needed package_parameters_[5], // oat_dir atoi(package_parameters_[6]), // dexopt_flags package_parameters_[7], // compiler_filter ParseNull(package_parameters_[8]), // volume_uuid ParseNull(package_parameters_[9])); // shared_libraries return ret; } } //////////////////////////////////// //////////////////////////////////// Loading Loading @@ -484,7 +476,7 @@ private: // to compile, instead of the A properties we could get from init/get_property. // to compile, instead of the A properties we could get from init/get_property. SystemProperties system_properties_; SystemProperties system_properties_; const char* package_parameters_[10]; const char* package_parameters_[DEXOPT_PARAM_COUNT]; // Store environment values we need to set. // Store environment values we need to set. std::vector<std::string> environ_; std::vector<std::string> environ_; Loading Loading
cmds/installd/commands.cpp +22 −0 Original line number Original line Diff line number Diff line Loading @@ -1385,6 +1385,28 @@ bool merge_profiles(uid_t uid, const char *pkgname) { return analyse_profiles(uid, pkgname); return analyse_profiles(uid, pkgname); } } static const char* parse_null(const char* arg) { if (strcmp(arg, "!") == 0) { return nullptr; } else { return arg; } } int dexopt(const char* params[DEXOPT_PARAM_COUNT]) { return dexopt(params[0], // apk_path atoi(params[1]), // uid params[2], // pkgname params[3], // instruction_set atoi(params[4]), // dexopt_needed params[5], // oat_dir atoi(params[6]), // dexopt_flags params[7], // compiler_filter parse_null(params[8]), // volume_uuid parse_null(params[9])); // shared_libraries static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param count"); } int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set, int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries) const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries) Loading
cmds/installd/commands.h +15 −3 Original line number Original line Diff line number Diff line Loading @@ -56,9 +56,21 @@ bool merge_profiles(uid_t uid, const char *pkgname); bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files); bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files); int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set, int dexopt(const char *apk_path, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, uid_t uid, const char* volume_uuid, const char* shared_libraries); const char *pkgName, const char *instruction_set, int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter, const char* volume_uuid, const char* shared_libraries); 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 mark_boot_complete(const char *instruction_set); int mark_boot_complete(const char *instruction_set); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); int idmap(const char *target_path, const char *overlay_path, uid_t uid); int idmap(const char *target_path, const char *overlay_path, uid_t uid); Loading
cmds/installd/installd.cpp +28 −17 Original line number Original line Diff line number Diff line Loading @@ -219,7 +219,8 @@ static int do_destroy_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSE // We use otapreopt_chroot to get into the chroot. // We use otapreopt_chroot to get into the chroot. static constexpr const char* kOtaPreopt = "/system/bin/otapreopt_chroot"; static constexpr const char* kOtaPreopt = "/system/bin/otapreopt_chroot"; static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { static int do_ota_dexopt(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { // Time to fork and run otapreopt. // Time to fork and run otapreopt. // Check that the tool exists. // Check that the tool exists. Loading @@ -231,12 +232,14 @@ static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { pid_t pid = fork(); pid_t pid = fork(); if (pid == 0) { if (pid == 0) { const char* argv[1 + 9 + 1]; const char* argv[1 + DEXOPT_PARAM_COUNT + 1]; argv[0] = kOtaPreopt; argv[0] = kOtaPreopt; for (size_t i = 1; i <= 9; ++i) { argv[i] = arg[i - 1]; for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) { argv[i + 1] = args[i]; } } argv[10] = nullptr; argv[DEXOPT_PARAM_COUNT + 1] = nullptr; execv(argv[0], (char * const *)argv); execv(argv[0], (char * const *)argv); PLOG(ERROR) << "execv(OTAPREOPT_CHROOT) failed"; PLOG(ERROR) << "execv(OTAPREOPT_CHROOT) failed"; Loading @@ -252,22 +255,30 @@ static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { } } } } static int do_regular_dexopt(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { return dexopt(args); } using DexoptFn = int (*)(const char* args[DEXOPT_PARAM_COUNT], char reply[REPLY_MAX]); static int do_dexopt(char **arg, char reply[REPLY_MAX]) static int do_dexopt(char **arg, char reply[REPLY_MAX]) { { const char* args[DEXOPT_PARAM_COUNT]; for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) { CHECK(arg[i] != nullptr); args[i] = arg[i]; } int dexopt_flags = atoi(arg[6]); int dexopt_flags = atoi(arg[6]); DexoptFn dexopt_fn; if ((dexopt_flags & DEXOPT_OTA) != 0) { if ((dexopt_flags & DEXOPT_OTA) != 0) { return do_ota_dexopt(arg, reply); dexopt_fn = do_ota_dexopt; } } else { return dexopt(arg[0], // apk_path dexopt_fn = do_regular_dexopt; atoi(arg[1]), // uid } arg[2], // pkgname return dexopt_fn(args, reply); arg[3], // instruction_set atoi(arg[4]), // dexopt_needed arg[5], // oat_dir dexopt_flags, arg[7], // compiler_filter parse_null(arg[8]), // volume_uuid parse_null(arg[9])); // shared_libraries } } static int do_merge_profiles(char **arg, char reply[REPLY_MAX]) static int do_merge_profiles(char **arg, char reply[REPLY_MAX]) Loading
cmds/installd/installd_constants.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ namespace android { namespace android { namespace installd { namespace installd { constexpr size_t DEXOPT_PARAM_COUNT = 10U; /* elements combined with a valid package name to form paths */ /* elements combined with a valid package name to form paths */ constexpr const char* PRIMARY_USER_PREFIX = "data/"; constexpr const char* PRIMARY_USER_PREFIX = "data/"; Loading
cmds/installd/otapreopt.cpp +6 −14 Original line number Original line Diff line number Diff line Loading @@ -188,12 +188,14 @@ private: bool ReadPackage(int argc ATTRIBUTE_UNUSED, char** argv) { bool ReadPackage(int argc ATTRIBUTE_UNUSED, char** argv) { size_t index = 0; size_t index = 0; while (index < ARRAY_SIZE(package_parameters_) && static_assert(DEXOPT_PARAM_COUNT == ARRAY_SIZE(package_parameters_), "Unexpected dexopt param count"); while (index < DEXOPT_PARAM_COUNT && argv[index + 1] != nullptr) { argv[index + 1] != nullptr) { package_parameters_[index] = argv[index + 1]; package_parameters_[index] = argv[index + 1]; index++; index++; } } if (index != ARRAY_SIZE(package_parameters_)) { if (index != ARRAY_SIZE(package_parameters_) || argv[index + 1] != nullptr) { LOG(ERROR) << "Wrong number of parameters"; LOG(ERROR) << "Wrong number of parameters"; return false; return false; } } Loading Loading @@ -357,17 +359,7 @@ private: } } int RunPreopt() { int RunPreopt() { int ret = dexopt(package_parameters_[0], // apk_path return dexopt(package_parameters_); atoi(package_parameters_[1]), // uid package_parameters_[2], // pkgname package_parameters_[3], // instruction_set atoi(package_parameters_[4]), // dexopt_needed package_parameters_[5], // oat_dir atoi(package_parameters_[6]), // dexopt_flags package_parameters_[7], // compiler_filter ParseNull(package_parameters_[8]), // volume_uuid ParseNull(package_parameters_[9])); // shared_libraries return ret; } } //////////////////////////////////// //////////////////////////////////// Loading Loading @@ -484,7 +476,7 @@ private: // to compile, instead of the A properties we could get from init/get_property. // to compile, instead of the A properties we could get from init/get_property. SystemProperties system_properties_; SystemProperties system_properties_; const char* package_parameters_[10]; const char* package_parameters_[DEXOPT_PARAM_COUNT]; // Store environment values we need to set. // Store environment values we need to set. std::vector<std::string> environ_; std::vector<std::string> environ_; Loading