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

Commit 249c1796 authored by David Brazdil's avatar David Brazdil
Browse files

installd: Simplify Dalvik cache path creation

Installd computes Dalvik cache path for a dex file by concatenating
'/classes.dex' to the APKs absolute path and then replacing all '/'
characters with '@'. OTA preopt does the same, only in reverse order,
i.e by concatenating '@classes.dex' to altered absolute path.

This patch unifies the two approaches so as to keep only one string
constant.

Change-Id: I69bb6bca831f45c873a0eb8580cf8d4b011f3b09
parent 6fabbc60
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -151,12 +151,11 @@ bool create_cache_path(char path[PKG_PATH_MAX],
        return false;
        return false;
    }
    }


    sprintf(path,"%s%s/%s/%s%s",
    sprintf(path,"%s%s/%s/%s",
            android_data_dir.path,
            android_data_dir.path,
            DALVIK_CACHE,
            DALVIK_CACHE,
            instruction_set,
            instruction_set,
            src + 1, /* skip the leading / */
            src + 1 /* skip the leading / */);
            DALVIK_CACHE_POSTFIX);


    char* tmp =
    char* tmp =
            path +
            path +
@@ -171,6 +170,7 @@ bool create_cache_path(char path[PKG_PATH_MAX],
        }
        }
    }
    }


    strcat(path, DALVIK_CACHE_POSTFIX);
    return true;
    return true;
}
}


+1 −2
Original line number Original line Diff line number Diff line
@@ -49,8 +49,7 @@ constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory unde


// This is used as a string literal, can't be constants. TODO: std::string...
// This is used as a string literal, can't be constants. TODO: std::string...
#define DALVIK_CACHE "dalvik-cache"
#define DALVIK_CACHE "dalvik-cache"
constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex";
constexpr const char* DALVIK_CACHE_POSTFIX = "@classes.dex";
constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex";


constexpr const char* IDMAP_PREFIX = "/data/resource-cache/";
constexpr const char* IDMAP_PREFIX = "/data/resource-cache/";
constexpr const char* IDMAP_SUFFIX = "@idmap";
constexpr const char* IDMAP_SUFFIX = "@idmap";
+1 −1
Original line number Original line Diff line number Diff line
@@ -590,7 +590,7 @@ bool create_cache_path(char path[PKG_PATH_MAX],
                                              DALVIK_CACHE,
                                              DALVIK_CACHE,
                                              instruction_set,
                                              instruction_set,
                                              from_src.c_str(),
                                              from_src.c_str(),
                                              DALVIK_CACHE_POSTFIX2);
                                              DALVIK_CACHE_POSTFIX);


    if (assembled_path.length() + 1 > PKG_PATH_MAX) {
    if (assembled_path.length() + 1 > PKG_PATH_MAX) {
        return false;
        return false;