summaryrefslogtreecommitdiffstats
path: root/cmds/app_process
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-04-25 11:43:22 +0100
committerNarayan Kamath <narayan@google.com>2014-05-01 11:26:49 +0100
commit973cdeed8eb9aa250b1b3bd5549df0e0dc78457e (patch)
treedc92e8b3a7cdc7b32f14ddaf0f85298ba9abdb8e /cmds/app_process
parentfbb0ab02bed5c49159acb3dba6848a154e524169 (diff)
downloadframeworks_base-973cdeed8eb9aa250b1b3bd5549df0e0dc78457e.zip
frameworks_base-973cdeed8eb9aa250b1b3bd5549df0e0dc78457e.tar.gz
frameworks_base-973cdeed8eb9aa250b1b3bd5549df0e0dc78457e.tar.bz2
Create arch specific cache dirs during zygote startup.
The runtime expects them to exist before it's launched. The boot image / art files are created during the first zygote launch. (cherry picked from commit da738713e4e2120a324e8ab6fd11aa0e54a3c66e) Change-Id: I7472aa25c16a1cf95791af2bdf80ed0d73123872
Diffstat (limited to 'cmds/app_process')
-rw-r--r--cmds/app_process/app_main.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 82d13a6..391c197 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -15,6 +15,7 @@
#include <cutils/properties.h>
#include <cutils/trace.h>
#include <android_runtime/AndroidRuntime.h>
+#include <private/android_filesystem_config.h> // for AID_SYSTEM
#include <stdlib.h>
#include <stdio.h>
@@ -137,6 +138,44 @@ static size_t computeArgBlockSize(int argc, char* const argv[]) {
return (end - start);
}
+static void maybeCreateDalvikCache() {
+#if defined(__aarch64__)
+ static const char kInstructionSet[] = "arm64";
+#elif defined(__x86_64__)
+ static const char kInstructionSet[] = "x86_64";
+#elif defined(__arm__)
+ static const char kInstructionSet[] = "arm";
+#elif defined(__x86__)
+ static const char kInstructionSet[] = "x86";
+#elif defined (__mips__)
+ static const char kInstructionSet[] = "mips";
+#else
+#error "Unknown instruction set"
+#endif
+ const char* androidRoot = getenv("ANDROID_DATA");
+ LOG_ALWAYS_FATAL_IF(androidRoot == NULL, "ANDROID_DATA environment variable unset");
+
+ char dalvikCacheDir[PATH_MAX];
+ const int numChars = snprintf(dalvikCacheDir, PATH_MAX,
+ "%s/dalvik-cache/%s", androidRoot, kInstructionSet);
+ LOG_ALWAYS_FATAL_IF((numChars >= PATH_MAX || numChars < 0),
+ "Error constructing dalvik cache : %s", strerror(errno));
+
+ int result = mkdir(dalvikCacheDir, 0771);
+ LOG_ALWAYS_FATAL_IF((result < 0 && errno != EEXIST),
+ "Error creating cache dir %s : %s", dalvikCacheDir, strerror(errno));
+
+ // We always perform these steps because the directory might
+ // already exist, with wider permissions and a different owner
+ // than we'd like.
+ result = chown(dalvikCacheDir, AID_SYSTEM, AID_SYSTEM);
+ LOG_ALWAYS_FATAL_IF((result < 0), "Error changing dalvik-cache ownership : %s", strerror(errno));
+
+ result = chmod(dalvikCacheDir, 0771);
+ LOG_ALWAYS_FATAL_IF((result < 0),
+ "Error changing dalvik-cache permissions : %s", strerror(errno));
+}
+
#if defined(__LP64__)
static const char ABI_LIST_PROPERTY[] = "ro.product.cpu.abilist64";
static const char ZYGOTE_NICE_NAME[] = "zygote64";
@@ -223,6 +262,9 @@ int main(int argc, char* const argv[])
args.add(application ? String8("application") : String8("tool"));
runtime.setClassNameAndArgs(className, argc - i, argv + i);
} else {
+ // We're in zygote mode.
+ maybeCreateDalvikCache();
+
if (startSystemServer) {
args.add(String8("start-system-server"));
}