summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2016-09-06 15:35:28 +0100
committer David Brazdil <dbrazdil@google.com> 2016-09-06 15:47:59 +0100
commit249c1796a2e62f8751348e5bafce9f40e6538cba (patch)
treeeed5b3c8816b8dc50476480a5e0f6723cde5123e /cmds
parent6fabbc60fc91fc60bbcc6bdabab005a2d31e9601 (diff)
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
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/installd.cpp6
-rw-r--r--cmds/installd/installd_constants.h3
-rw-r--r--cmds/installd/otapreopt.cpp2
3 files changed, 5 insertions, 6 deletions
diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp
index 1583f86cea..d5c3ccda4e 100644
--- a/cmds/installd/installd.cpp
+++ b/cmds/installd/installd.cpp
@@ -151,12 +151,11 @@ bool create_cache_path(char path[PKG_PATH_MAX],
return false;
}
- sprintf(path,"%s%s/%s/%s%s",
+ sprintf(path,"%s%s/%s/%s",
android_data_dir.path,
DALVIK_CACHE,
instruction_set,
- src + 1, /* skip the leading / */
- DALVIK_CACHE_POSTFIX);
+ src + 1 /* skip the leading / */);
char* tmp =
path +
@@ -171,6 +170,7 @@ bool create_cache_path(char path[PKG_PATH_MAX],
}
}
+ strcat(path, DALVIK_CACHE_POSTFIX);
return true;
}
diff --git a/cmds/installd/installd_constants.h b/cmds/installd/installd_constants.h
index 8513695ef3..dfde7274bc 100644
--- a/cmds/installd/installd_constants.h
+++ b/cmds/installd/installd_constants.h
@@ -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...
#define DALVIK_CACHE "dalvik-cache"
-constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex";
-constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex";
+constexpr const char* DALVIK_CACHE_POSTFIX = "@classes.dex";
constexpr const char* IDMAP_PREFIX = "/data/resource-cache/";
constexpr const char* IDMAP_SUFFIX = "@idmap";
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index 3f767701c9..8b9c931ea2 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -590,7 +590,7 @@ bool create_cache_path(char path[PKG_PATH_MAX],
DALVIK_CACHE,
instruction_set,
from_src.c_str(),
- DALVIK_CACHE_POSTFIX2);
+ DALVIK_CACHE_POSTFIX);
if (assembled_path.length() + 1 > PKG_PATH_MAX) {
return false;