Loading cmds/installd/InstalldNativeService.cpp +14 −8 Original line number Diff line number Diff line Loading @@ -1895,13 +1895,18 @@ binder::Status InstalldNativeService::destroyProfileSnapshot(const std::string& return ok(); } static const char* getCStr(const std::unique_ptr<std::string>& data, const char* default_value = nullptr) { return data == nullptr ? default_value : data->c_str(); } binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t uid, const std::unique_ptr<std::string>& packageName, const std::string& instructionSet, int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags, const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid, const std::unique_ptr<std::string>& classLoaderContext, const std::unique_ptr<std::string>& seInfo, bool downgrade, int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName) { const std::unique_ptr<std::string>& profileName, const std::unique_ptr<std::string>& dexMetadataPath) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_UUID(uuid); if (packageName && *packageName != "*") { Loading @@ -1910,17 +1915,18 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t std::lock_guard<std::recursive_mutex> lock(mLock); const char* apk_path = apkPath.c_str(); const char* pkgname = packageName ? packageName->c_str() : "*"; const char* pkgname = getCStr(packageName, "*"); const char* instruction_set = instructionSet.c_str(); const char* oat_dir = outputPath ? outputPath->c_str() : nullptr; const char* oat_dir = getCStr(outputPath); const char* compiler_filter = compilerFilter.c_str(); const char* volume_uuid = uuid ? uuid->c_str() : nullptr; const char* class_loader_context = classLoaderContext ? classLoaderContext->c_str() : nullptr; const char* se_info = seInfo ? seInfo->c_str() : nullptr; const char* profile_name = profileName ? profileName->c_str() : nullptr; const char* volume_uuid = getCStr(uuid); const char* class_loader_context = getCStr(classLoaderContext); const char* se_info = getCStr(seInfo); const char* profile_name = getCStr(profileName); const char* dm_path = getCStr(dexMetadataPath); int res = android::installd::dexopt(apk_path, uid, pkgname, instruction_set, dexoptNeeded, oat_dir, dexFlags, compiler_filter, volume_uuid, class_loader_context, se_info, downgrade, targetSdkVersion, profile_name); downgrade, targetSdkVersion, profile_name, dm_path); return res ? error(res, "Failed to dexopt") : ok(); } Loading cmds/installd/InstalldNativeService.h +2 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public: const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid, const std::unique_ptr<std::string>& classLoaderContext, const std::unique_ptr<std::string>& seInfo, bool downgrade, int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName); int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName, const std::unique_ptr<std::string>& dexMetadataPath); binder::Status rmdex(const std::string& codePath, const std::string& instructionSet); Loading cmds/installd/binder/android/os/IInstalld.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ interface IInstalld { @utf8InCpp String compilerFilter, @nullable @utf8InCpp String uuid, @nullable @utf8InCpp String sharedLibraries, @nullable @utf8InCpp String seInfo, boolean downgrade, int targetSdkVersion, @nullable @utf8InCpp String profileName); @nullable @utf8InCpp String profileName, @nullable @utf8InCpp String dexMetadataPath); void rmdex(@utf8InCpp String codePath, @utf8InCpp String instructionSet); Loading cmds/installd/dexopt.cpp +20 −4 Original line number Diff line number Diff line Loading @@ -223,7 +223,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd const char* input_file_name, const char* output_file_name, int swap_fd, const char* instruction_set, const char* compiler_filter, bool debuggable, bool post_bootcomplete, bool background_job_compile, int profile_fd, const char* class_loader_context, int target_sdk_version, bool disable_hidden_api_checks) { const char* class_loader_context, int target_sdk_version, bool disable_hidden_api_checks, int dex_metadata_fd) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) { Loading Loading @@ -420,6 +421,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd sprintf(base_dir, "--classpath-dir=%s", apk_dir.c_str()); } std::string dex_metadata_fd_arg = "--dm-fd=" + std::to_string(dex_metadata_fd); ALOGV("Running %s in=%s out=%s\n", dex2oat_bin, relative_input_file_name, output_file_name); Loading Loading @@ -450,7 +452,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd + (disable_cdex ? 1 : 0) + (generate_minidebug_info ? 1 : 0) + (target_sdk_version != 0 ? 2 : 0) + (disable_hidden_api_checks ? 2 : 0)]; + (disable_hidden_api_checks ? 2 : 0) + (dex_metadata_fd > -1 ? 1 : 0)]; int i = 0; argv[i++] = dex2oat_bin; argv[i++] = zip_fd_arg; Loading Loading @@ -529,6 +532,9 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd argv[i++] = "-Xno-hidden-api-checks"; } if (dex_metadata_fd > -1) { argv[i++] = dex_metadata_fd_arg.c_str(); } // Do not add after dex2oat_flags, they should override others for debugging. argv[i] = NULL; Loading Loading @@ -1846,7 +1852,8 @@ static bool process_secondary_dex_dexopt(const std::string& dex_path, const char int dexopt(const char* dex_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, const char* volume_uuid, const char* class_loader_context, const char* se_info, bool downgrade, int target_sdk_version, const char* profile_name) { bool downgrade, int target_sdk_version, const char* profile_name, const char* dex_metadata_path) { CHECK(pkgname != nullptr); CHECK(pkgname[0] != 0); if ((dexopt_flags & ~DEXOPT_MASK) != 0) { Loading Loading @@ -1937,6 +1944,14 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins Dex2oatFileWrapper reference_profile_fd = maybe_open_reference_profile( pkgname, dex_path, profile_name, profile_guided, is_public, uid, is_secondary_dex); unique_fd dex_metadata_fd; if (dex_metadata_path != nullptr) { dex_metadata_fd.reset(TEMP_FAILURE_RETRY(open(dex_metadata_path, O_RDONLY | O_NOFOLLOW))); if (dex_metadata_fd.get() < 0) { PLOG(ERROR) << "Failed to open dex metadata file " << dex_metadata_path; } } ALOGV("DexInv: --- BEGIN '%s' ---\n", dex_path); pid_t pid = fork(); Loading Loading @@ -1966,7 +1981,8 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins reference_profile_fd.get(), class_loader_context, target_sdk_version, disable_hidden_api_checks); disable_hidden_api_checks, dex_metadata_fd.get()); _exit(68); /* only get here on exec failure */ } else { int res = wait_child(pid); Loading cmds/installd/dexopt.h +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ bool hash_secondary_dex_file(const std::string& dex_path, 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, const char* volume_uuid, const char* class_loader_context, const char* se_info, bool downgrade, int target_sdk_version, const char* profile_name); bool downgrade, int target_sdk_version, const char* profile_name, const char* dexMetadataPath); bool calculate_oat_file_path_default(char path[PKG_PATH_MAX], const char *oat_dir, const char *apk_path, const char *instruction_set); Loading Loading
cmds/installd/InstalldNativeService.cpp +14 −8 Original line number Diff line number Diff line Loading @@ -1895,13 +1895,18 @@ binder::Status InstalldNativeService::destroyProfileSnapshot(const std::string& return ok(); } static const char* getCStr(const std::unique_ptr<std::string>& data, const char* default_value = nullptr) { return data == nullptr ? default_value : data->c_str(); } binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t uid, const std::unique_ptr<std::string>& packageName, const std::string& instructionSet, int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags, const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid, const std::unique_ptr<std::string>& classLoaderContext, const std::unique_ptr<std::string>& seInfo, bool downgrade, int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName) { const std::unique_ptr<std::string>& profileName, const std::unique_ptr<std::string>& dexMetadataPath) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_UUID(uuid); if (packageName && *packageName != "*") { Loading @@ -1910,17 +1915,18 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t std::lock_guard<std::recursive_mutex> lock(mLock); const char* apk_path = apkPath.c_str(); const char* pkgname = packageName ? packageName->c_str() : "*"; const char* pkgname = getCStr(packageName, "*"); const char* instruction_set = instructionSet.c_str(); const char* oat_dir = outputPath ? outputPath->c_str() : nullptr; const char* oat_dir = getCStr(outputPath); const char* compiler_filter = compilerFilter.c_str(); const char* volume_uuid = uuid ? uuid->c_str() : nullptr; const char* class_loader_context = classLoaderContext ? classLoaderContext->c_str() : nullptr; const char* se_info = seInfo ? seInfo->c_str() : nullptr; const char* profile_name = profileName ? profileName->c_str() : nullptr; const char* volume_uuid = getCStr(uuid); const char* class_loader_context = getCStr(classLoaderContext); const char* se_info = getCStr(seInfo); const char* profile_name = getCStr(profileName); const char* dm_path = getCStr(dexMetadataPath); int res = android::installd::dexopt(apk_path, uid, pkgname, instruction_set, dexoptNeeded, oat_dir, dexFlags, compiler_filter, volume_uuid, class_loader_context, se_info, downgrade, targetSdkVersion, profile_name); downgrade, targetSdkVersion, profile_name, dm_path); return res ? error(res, "Failed to dexopt") : ok(); } Loading
cmds/installd/InstalldNativeService.h +2 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public: const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid, const std::unique_ptr<std::string>& classLoaderContext, const std::unique_ptr<std::string>& seInfo, bool downgrade, int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName); int32_t targetSdkVersion, const std::unique_ptr<std::string>& profileName, const std::unique_ptr<std::string>& dexMetadataPath); binder::Status rmdex(const std::string& codePath, const std::string& instructionSet); Loading
cmds/installd/binder/android/os/IInstalld.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ interface IInstalld { @utf8InCpp String compilerFilter, @nullable @utf8InCpp String uuid, @nullable @utf8InCpp String sharedLibraries, @nullable @utf8InCpp String seInfo, boolean downgrade, int targetSdkVersion, @nullable @utf8InCpp String profileName); @nullable @utf8InCpp String profileName, @nullable @utf8InCpp String dexMetadataPath); void rmdex(@utf8InCpp String codePath, @utf8InCpp String instructionSet); Loading
cmds/installd/dexopt.cpp +20 −4 Original line number Diff line number Diff line Loading @@ -223,7 +223,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd const char* input_file_name, const char* output_file_name, int swap_fd, const char* instruction_set, const char* compiler_filter, bool debuggable, bool post_bootcomplete, bool background_job_compile, int profile_fd, const char* class_loader_context, int target_sdk_version, bool disable_hidden_api_checks) { const char* class_loader_context, int target_sdk_version, bool disable_hidden_api_checks, int dex_metadata_fd) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) { Loading Loading @@ -420,6 +421,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd sprintf(base_dir, "--classpath-dir=%s", apk_dir.c_str()); } std::string dex_metadata_fd_arg = "--dm-fd=" + std::to_string(dex_metadata_fd); ALOGV("Running %s in=%s out=%s\n", dex2oat_bin, relative_input_file_name, output_file_name); Loading Loading @@ -450,7 +452,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd + (disable_cdex ? 1 : 0) + (generate_minidebug_info ? 1 : 0) + (target_sdk_version != 0 ? 2 : 0) + (disable_hidden_api_checks ? 2 : 0)]; + (disable_hidden_api_checks ? 2 : 0) + (dex_metadata_fd > -1 ? 1 : 0)]; int i = 0; argv[i++] = dex2oat_bin; argv[i++] = zip_fd_arg; Loading Loading @@ -529,6 +532,9 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd argv[i++] = "-Xno-hidden-api-checks"; } if (dex_metadata_fd > -1) { argv[i++] = dex_metadata_fd_arg.c_str(); } // Do not add after dex2oat_flags, they should override others for debugging. argv[i] = NULL; Loading Loading @@ -1846,7 +1852,8 @@ static bool process_secondary_dex_dexopt(const std::string& dex_path, const char int dexopt(const char* dex_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, const char* volume_uuid, const char* class_loader_context, const char* se_info, bool downgrade, int target_sdk_version, const char* profile_name) { bool downgrade, int target_sdk_version, const char* profile_name, const char* dex_metadata_path) { CHECK(pkgname != nullptr); CHECK(pkgname[0] != 0); if ((dexopt_flags & ~DEXOPT_MASK) != 0) { Loading Loading @@ -1937,6 +1944,14 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins Dex2oatFileWrapper reference_profile_fd = maybe_open_reference_profile( pkgname, dex_path, profile_name, profile_guided, is_public, uid, is_secondary_dex); unique_fd dex_metadata_fd; if (dex_metadata_path != nullptr) { dex_metadata_fd.reset(TEMP_FAILURE_RETRY(open(dex_metadata_path, O_RDONLY | O_NOFOLLOW))); if (dex_metadata_fd.get() < 0) { PLOG(ERROR) << "Failed to open dex metadata file " << dex_metadata_path; } } ALOGV("DexInv: --- BEGIN '%s' ---\n", dex_path); pid_t pid = fork(); Loading Loading @@ -1966,7 +1981,8 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins reference_profile_fd.get(), class_loader_context, target_sdk_version, disable_hidden_api_checks); disable_hidden_api_checks, dex_metadata_fd.get()); _exit(68); /* only get here on exec failure */ } else { int res = wait_child(pid); Loading
cmds/installd/dexopt.h +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ bool hash_secondary_dex_file(const std::string& dex_path, 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, const char* volume_uuid, const char* class_loader_context, const char* se_info, bool downgrade, int target_sdk_version, const char* profile_name); bool downgrade, int target_sdk_version, const char* profile_name, const char* dexMetadataPath); bool calculate_oat_file_path_default(char path[PKG_PATH_MAX], const char *oat_dir, const char *apk_path, const char *instruction_set); Loading