Merge changes from topic "native_bridge_for_app_zygote"

am: 5f30976b8c

Change-Id: I45f72fec13fa586eee1b9d2d97d7f0a06dd0877e
This commit is contained in:
Lev Rumyantsev
2020-01-21 15:18:57 -08:00
committed by android-build-merger

View File

@@ -1063,22 +1063,16 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
DropCapabilitiesBoundingSet(fail_fn); DropCapabilitiesBoundingSet(fail_fn);
bool use_native_bridge = !is_system_server && bool need_pre_initialize_native_bridge =
instruction_set.has_value() && !is_system_server &&
android::NativeBridgeAvailable() && instruction_set.has_value() &&
android::NeedsNativeBridge(instruction_set.value().c_str()); android::NativeBridgeAvailable() &&
// Native bridge may be already initialized if this
// is an app forked from app-zygote.
!android::NativeBridgeInitialized() &&
android::NeedsNativeBridge(instruction_set.value().c_str());
if (use_native_bridge && !app_data_dir.has_value()) { MountEmulatedStorage(uid, mount_external, need_pre_initialize_native_bridge, fail_fn);
// The app_data_dir variable should never be empty if we need to use a
// native bridge. In general, app_data_dir will never be empty for normal
// applications. It can only happen in special cases (for isolated
// processes which are not associated with any app). These are launched by
// the framework and should not be emulated anyway.
use_native_bridge = false;
ALOGW("Native bridge will not be used because managed_app_data_dir == nullptr.");
}
MountEmulatedStorage(uid, mount_external, use_native_bridge, fail_fn);
// If this zygote isn't root, it won't be able to create a process group, // If this zygote isn't root, it won't be able to create a process group,
// since the directory is owned by root. // since the directory is owned by root.
@@ -1094,11 +1088,12 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
SetGids(env, gids, fail_fn); SetGids(env, gids, fail_fn);
SetRLimits(env, rlimits, fail_fn); SetRLimits(env, rlimits, fail_fn);
if (use_native_bridge) { if (need_pre_initialize_native_bridge) {
// Due to the logic behind use_native_bridge we know that both app_data_dir // Due to the logic behind need_pre_initialize_native_bridge we know that
// and instruction_set contain values. // instruction_set contains a value.
android::PreInitializeNativeBridge(app_data_dir.value().c_str(), android::PreInitializeNativeBridge(
instruction_set.value().c_str()); app_data_dir.has_value() ? app_data_dir.value().c_str() : nullptr,
instruction_set.value().c_str());
} }
if (setresgid(gid, gid, gid) == -1) { if (setresgid(gid, gid, gid) == -1) {