diff options
| author | Calin Juravle <calin@google.com> | 2014-10-24 16:16:49 +0100 |
|---|---|---|
| committer | Calin Juravle <calin@google.com> | 2014-10-29 13:16:44 +0000 |
| commit | e9d6743649eb0e767ba46d9d8ac0d94f15b8c318 (patch) | |
| tree | ef2cca99da450913e8e806de6eb4a8c5e53e7211 | |
| parent | b9e290c7136fb7c76b7238426ccd598dec2d2643 (diff) | |
| download | frameworks_base-e9d6743649eb0e767ba46d9d8ac0d94f15b8c318.zip frameworks_base-e9d6743649eb0e767ba46d9d8ac0d94f15b8c318.tar.gz frameworks_base-e9d6743649eb0e767ba46d9d8ac0d94f15b8c318.tar.bz2 | |
PreInitializeNativeBridge only if its Available
Also, assert that we always have a private application directory for non
system_server case.
Bug: 18027433
(cherry picked from commit 79ec4c15ab941419d21700a9734f5238b975c31a)
Change-Id: I9ce578949dbe522d5033465df7ca49fdd3aa3cbf
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 7ca9374..1eb83b2 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -436,6 +436,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra pid_t pid = fork(); if (pid == 0) { + if (!is_system_server && dataDir == NULL) { + ALOGE("Application private dir cannot be null"); + RuntimeAbort(env); + } // The child process. gMallocLeakZygoteChild = 1; @@ -452,14 +456,15 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra DropCapabilitiesBoundingSet(env); - bool need_native_bridge = false; - if (instructionSet != NULL) { + bool use_native_bridge = !is_system_server && (instructionSet != NULL) + && android::NativeBridgeAvailable(); + if (use_native_bridge) { ScopedUtfChars isa_string(env, instructionSet); - need_native_bridge = android::NeedsNativeBridge(isa_string.c_str()); + use_native_bridge = android::NeedsNativeBridge(isa_string.c_str()); } - if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) { - ALOGW("Failed to mount emulated storage: %d", errno); + if (!MountEmulatedStorage(uid, mount_external, use_native_bridge)) { + ALOGW("Failed to mount emulated storage: %s", strerror(errno)); if (errno == ENOTCONN || errno == EROFS) { // When device is actively encrypting, we get ENOTCONN here // since FUSE was mounted before the framework restarted. @@ -487,15 +492,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra SetRLimits(env, javaRlimits); - if (!is_system_server && need_native_bridge) { - // Set the environment for the apps running with native bridge. - ScopedUtfChars isa_string(env, instructionSet); // Known non-null because of need_native_... - if (dataDir == NULL) { - android::PreInitializeNativeBridge(NULL, isa_string.c_str()); - } else { - ScopedUtfChars data_dir(env, dataDir); - android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str()); - } + if (use_native_bridge) { + ScopedUtfChars isa_string(env, instructionSet); + ScopedUtfChars data_dir(env, dataDir); + android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str()); } int rc = setresgid(gid, gid, gid); |
