aboutsummaryrefslogtreecommitdiff
path: root/libdex/OptInvocation.cpp
diff options
context:
space:
mode:
authorctso <ctsoyars@gmail.com>2010-06-24 02:04:16 +0000
committerSteve Kondik <shade@chemlab.org>2013-07-24 12:55:21 -0700
commit210ad4902c02500e55ec7e2e8b10f7079da442e2 (patch)
tree206b93de5ce6713e37a76d7810fe5bb59ac66a81 /libdex/OptInvocation.cpp
parent8bab45388ae371ba918c1c6d23b0dd269fcee406 (diff)
DexOpt anything in /system on /cache
Allow system property to disable use of /cache for dexfiles. (manually cherry-picked commit 15d27bbe10e307136e081bedb7cf25131896f1cb)
Diffstat (limited to 'libdex/OptInvocation.cpp')
-rw-r--r--libdex/OptInvocation.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/libdex/OptInvocation.cpp b/libdex/OptInvocation.cpp
index bac2f247d..7a25c2954 100644
--- a/libdex/OptInvocation.cpp
+++ b/libdex/OptInvocation.cpp
@@ -32,6 +32,8 @@
#include "OptInvocation.h"
#include "DexFile.h"
+#include <cutils/properties.h>
+
static const char* kCacheDirectoryName = "dalvik-cache";
static const char* kClassesDex = "classes.dex";
@@ -50,7 +52,11 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)
char absoluteFile[sizeof(nameBuf)];
const size_t kBufLen = sizeof(nameBuf) - 1;
const char* dataRoot;
+ const char* dexRoot;
+ const char* cacheRoot;
+ const char* systemRoot;
char* cp;
+ char dexoptDataOnly[PROPERTY_VALUE_MAX];
/*
* Get the absolute path of the Jar or DEX file.
@@ -93,10 +99,34 @@ char* dexOptGenerateCacheFileName(const char* fileName, const char* subFileName)
/* Build the name of the cache directory.
*/
+
+ /* load paths from the system environment */
+ cacheRoot = getenv("ANDROID_CACHE");
dataRoot = getenv("ANDROID_DATA");
+ systemRoot = getenv("ANDROID_ROOT");
+
+ /* make sure we didn't get any NULL values */
+ if (cacheRoot == NULL)
+ cacheRoot = "/cache";
+
if (dataRoot == NULL)
dataRoot = "/data";
- snprintf(nameBuf, kBufLen, "%s/%s", dataRoot, kCacheDirectoryName);
+
+ if (systemRoot == NULL)
+ systemRoot = "/system";
+
+ if (dexRoot == NULL)
+ dexRoot = "/data";
+
+ /* Cache anything stored on /system in cacheRoot, everything else in dataRoot */
+ if (!strncmp(absoluteFile, systemRoot, strlen(systemRoot))) {
+ property_get("dalvik.vm.dexopt-data-only", dexoptDataOnly, "");
+ if (strcmp(dexoptDataOnly, "1") != 0) {
+ dexRoot = cacheRoot;
+ }
+ }
+
+ snprintf(nameBuf, kBufLen, "%s/%s", dexRoot, kCacheDirectoryName);
/* Tack on the file name for the actual cache file path.
*/