Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2efc402a authored by Calin Juravle's avatar Calin Juravle
Browse files

[installd] Pass --compilation-reason to dex2oat

Test: installd_dexopt_test, installd_otapreopt_test
Bug: 73102540

Change-Id: I22854f040c08ea3207860f29b374c66fe2f21750
parent eb7ea99a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1888,7 +1888,8 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t
        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>& dexMetadataPath) {
        const std::unique_ptr<std::string>& dexMetadataPath,
        const std::unique_ptr<std::string>& compilationReason) {
    ENFORCE_UID(AID_SYSTEM);
    CHECK_ARGUMENT_UUID(uuid);
    if (packageName && *packageName != "*") {
@@ -1906,9 +1907,10 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t
    const char* se_info = getCStr(seInfo);
    const char* profile_name = getCStr(profileName);
    const char* dm_path = getCStr(dexMetadataPath);
    const char* compilation_reason = getCStr(compilationReason);
    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, dm_path);
            downgrade, targetSdkVersion, profile_name, dm_path, compilation_reason);
    return res ? error(res, "Failed to dexopt") : ok();
}

+2 −1
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ public:
            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>& dexMetadataPath);
            const std::unique_ptr<std::string>& dexMetadataPath,
            const std::unique_ptr<std::string>& compilationReason);

    binder::Status rmdex(const std::string& codePath, const std::string& instructionSet);

+2 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ interface IInstalld {
            @nullable @utf8InCpp String sharedLibraries,
            @nullable @utf8InCpp String seInfo, boolean downgrade, int targetSdkVersion,
            @nullable @utf8InCpp String profileName,
            @nullable @utf8InCpp String dexMetadataPath);
            @nullable @utf8InCpp String dexMetadataPath,
            @nullable @utf8InCpp String compilationReason);

    void rmdex(@utf8InCpp String codePath, @utf8InCpp String instructionSet);

+14 −4
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
        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 enable_hidden_api_checks,
        int dex_metadata_fd) {
        int dex_metadata_fd, const char* compilation_reason) {
    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;

    if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
@@ -423,6 +423,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd

    std::string dex_metadata_fd_arg = "--dm-fd=" + std::to_string(dex_metadata_fd);

    std::string compilation_reason_arg = compilation_reason == nullptr
            ? ""
            : std::string("--compilation-reason=") + compilation_reason;

    ALOGV("Running %s in=%s out=%s\n", dex2oat_bin, relative_input_file_name, output_file_name);

    // Disable cdex if update input vdex is true since this combination of options is not
@@ -453,7 +457,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
                     + (generate_minidebug_info ? 1 : 0)
                     + (target_sdk_version != 0 ? 2 : 0)
                     + (enable_hidden_api_checks ? 2 : 0)
                     + (dex_metadata_fd > -1 ? 1 : 0)];
                     + (dex_metadata_fd > -1 ? 1 : 0)
                     + (compilation_reason != nullptr ? 1 : 0)];
    int i = 0;
    argv[i++] = dex2oat_bin;
    argv[i++] = zip_fd_arg;
@@ -535,6 +540,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
    if (dex_metadata_fd > -1) {
        argv[i++] = dex_metadata_fd_arg.c_str();
    }

    if(compilation_reason != nullptr) {
        argv[i++] = compilation_reason_arg.c_str();
    }
    // Do not add after dex2oat_flags, they should override others for debugging.
    argv[i] = NULL;

@@ -1865,7 +1874,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
        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,
        const char* dex_metadata_path) {
        const char* dex_metadata_path, const char* compilation_reason) {
    CHECK(pkgname != nullptr);
    CHECK(pkgname[0] != 0);
    if ((dexopt_flags & ~DEXOPT_MASK) != 0) {
@@ -1994,7 +2003,8 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
                    class_loader_context,
                    target_sdk_version,
                    enable_hidden_api_checks,
                    dex_metadata_fd.get());
                    dex_metadata_fd.get(),
                    compilation_reason);
        _exit(68);   /* only get here on exec failure */
    } else {
        int res = wait_child(pid);
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *ins
        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,
        const char* dexMetadataPath);
        const char* dexMetadataPath, const char* compilation_reason);

bool calculate_oat_file_path_default(char path[PKG_PATH_MAX], const char *oat_dir,
        const char *apk_path, const char *instruction_set);
Loading