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

Commit 8161da7a authored by Calin Juravle's avatar Calin Juravle Committed by Gerrit Code Review
Browse files

Merge "Remove obsolete profile handling from installd."

parents 81960fac df9dadd5
Loading
Loading
Loading
Loading
+3 −40
Original line number Diff line number Diff line
@@ -83,8 +83,6 @@ int uninstall(const char *uuid, const char *pkgname, userid_t userid)
    std::string _pkgdir(create_data_user_package_path(uuid, userid, pkgname));
    const char* pkgdir = _pkgdir.c_str();

    remove_profile_file(pkgname);

    /* delete contents AND directory, no exceptions */
    return delete_dir_contents(pkgdir, 1, NULL);
}
@@ -745,7 +743,7 @@ static bool check_boolean_property(const char* property_name, bool default_value
}

static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set,
    const char* output_file_name, int swap_fd, const char *instruction_set,
    bool vm_safe_mode, bool debuggable, bool post_bootcomplete, bool use_jit)
{
    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
@@ -756,9 +754,6 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
        return;
    }

    char prop_buf[PROPERTY_VALUE_MAX];
    bool profiler = (property_get("dalvik.vm.profiler", prop_buf, "0") > 0) && (prop_buf[0] == '1');

    char dex2oat_Xms_flag[PROPERTY_VALUE_MAX];
    bool have_dex2oat_Xms_flag = property_get("dalvik.vm.dex2oat-Xms", dex2oat_Xms_flag, NULL) > 0;

@@ -822,8 +817,6 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
    char instruction_set_variant_arg[strlen("--instruction-set-variant=") + PROPERTY_VALUE_MAX];
    char instruction_set_features_arg[strlen("--instruction-set-features=") + PROPERTY_VALUE_MAX];
    char profile_file_arg[strlen("--profile-file=") + PKG_PATH_MAX];
    char top_k_profile_threshold_arg[strlen("--top-k-profile-threshold=") + PROPERTY_VALUE_MAX];
    char dex2oat_Xms_arg[strlen("-Xms") + PROPERTY_VALUE_MAX];
    char dex2oat_Xmx_arg[strlen("-Xmx") + PROPERTY_VALUE_MAX];
    char dex2oat_compiler_filter_arg[strlen("--compiler-filter=") + PROPERTY_VALUE_MAX];
@@ -842,24 +835,6 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
        sprintf(dex2oat_swap_fd, "--swap-fd=%d", swap_fd);
    }

    bool have_profile_file = false;
    bool have_top_k_profile_threshold = false;
    if (profiler && (strcmp(pkgname, "*") != 0)) {
        char profile_file[PKG_PATH_MAX];
        snprintf(profile_file, sizeof(profile_file), "%s/%s",
                 DALVIK_CACHE_PREFIX "profiles", pkgname);
        struct stat st;
        if ((stat(profile_file, &st) == 0) && (st.st_size > 0)) {
            sprintf(profile_file_arg, "--profile-file=%s", profile_file);
            have_profile_file = true;
            if (property_get("dalvik.vm.profile.top-k-thr", prop_buf, NULL) > 0) {
                snprintf(top_k_profile_threshold_arg, sizeof(top_k_profile_threshold_arg),
                         "--top-k-profile-threshold=%s", prop_buf);
                have_top_k_profile_threshold = true;
            }
        }
    }

    // use the JIT if either it's specified as a dexopt flag or if the property is set
    use_jit = use_jit || check_boolean_property("debug.usejit");
    if (have_dex2oat_Xms_flag) {
@@ -884,6 +859,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,

    // Check whether all apps should be compiled debuggable.
    if (!debuggable) {
        char prop_buf[PROPERTY_VALUE_MAX];
        debuggable =
                (property_get("dalvik.vm.always_debuggable", prop_buf, "0") > 0) &&
                (prop_buf[0] == '1');
@@ -894,8 +870,6 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    const char* argv[7  // program name, mandatory arguments and the final NULL
                     + (have_dex2oat_isa_variant ? 1 : 0)
                     + (have_dex2oat_isa_features ? 1 : 0)
                     + (have_profile_file ? 1 : 0)
                     + (have_top_k_profile_threshold ? 1 : 0)
                     + (have_dex2oat_Xms_flag ? 2 : 0)
                     + (have_dex2oat_Xmx_flag ? 2 : 0)
                     + (have_dex2oat_compiler_filter_flag ? 1 : 0)
@@ -918,12 +892,6 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    if (have_dex2oat_isa_features) {
        argv[i++] = instruction_set_features_arg;
    }
    if (have_profile_file) {
        argv[i++] = profile_file_arg;
    }
    if (have_top_k_profile_threshold) {
        argv[i++] = top_k_profile_threshold_arg;
    }
    if (have_dex2oat_Xms_flag) {
        argv[i++] = RUNTIME_ARG;
        argv[i++] = dex2oat_Xms_arg;
@@ -1171,11 +1139,6 @@ int dexopt(const char *apk_path, uid_t uid, const char *pkgname, const char *ins
        goto fail;
    }

    // Create profile file if there is a package name present.
    if (strcmp(pkgname, "*") != 0) {
        create_profile_file(pkgname, uid);
    }

    // Create a swap file if necessary.
    if (ShouldUseSwapFileForDexopt()) {
        // Make sure there really is enough space.
@@ -1239,7 +1202,7 @@ int dexopt(const char *apk_path, uid_t uid, const char *pkgname, const char *ins
            } else {
                input_file_name++;
            }
            run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname,
            run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd,
                        instruction_set, vm_safe_mode, debuggable, boot_complete, use_jit);
        } else {
            ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
+8 −10
Original line number Diff line number Diff line
@@ -231,8 +231,6 @@ char *build_string3(const char *s1, const char *s2, const char *s3);
int ensure_dir(const char* path, mode_t mode, uid_t uid, gid_t gid);
int ensure_media_user_dirs(const char* uuid, userid_t userid);
int ensure_config_user_dirs(userid_t userid);
int create_profile_file(const char *pkgname, gid_t gid);
void remove_profile_file(const char *pkgname);

/* commands.c */

+0 −39
Original line number Diff line number Diff line
@@ -1143,42 +1143,3 @@ int ensure_config_user_dirs(userid_t userid) {

   return 0;
}

int create_profile_file(const char *pkgname, gid_t gid) {
    const char *profile_dir = DALVIK_CACHE_PREFIX "profiles";
    char profile_file[PKG_PATH_MAX];

    snprintf(profile_file, sizeof(profile_file), "%s/%s", profile_dir, pkgname);

    // The 'system' user needs to be able to read the profile to determine if dex2oat
    // needs to be run.  This is done in dalvik.system.DexFile.isDexOptNeededInternal().  So
    // we assign ownership to AID_SYSTEM and ensure it's not world-readable.

    int fd = open(profile_file, O_WRONLY | O_CREAT | O_NOFOLLOW | O_CLOEXEC, 0660);

    // Always set the uid/gid/permissions. The file could have been previously created
    // with different permissions.
    if (fd >= 0) {
        if (fchown(fd, AID_SYSTEM, gid) < 0) {
            ALOGE("cannot chown profile file '%s': %s\n", profile_file, strerror(errno));
            close(fd);
            unlink(profile_file);
            return -1;
        }

        if (fchmod(fd, 0660) < 0) {
            ALOGE("cannot chmod profile file '%s': %s\n", profile_file, strerror(errno));
            close(fd);
            unlink(profile_file);
            return -1;
        }
        close(fd);
    }
    return 0;
}

void remove_profile_file(const char *pkgname) {
    char profile_file[PKG_PATH_MAX];
    snprintf(profile_file, sizeof(profile_file), "%s/%s", DALVIK_CACHE_PREFIX "profiles", pkgname);
    unlink(profile_file);
}