com_android_internal_os_Zygote.cpp revision 7d28ad9b638a8184ab499cbe708d3427025e569b
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#define LOG_TAG "Zygote" 18 19// sys/mount.h has to come before linux/fs.h due to redefinition of MS_RDONLY, MS_BIND, etc 20#include <sys/mount.h> 21#include <linux/fs.h> 22 23#include <list> 24#include <string> 25 26#include <fcntl.h> 27#include <grp.h> 28#include <inttypes.h> 29#include <mntent.h> 30#include <paths.h> 31#include <signal.h> 32#include <stdlib.h> 33#include <sys/capability.h> 34#include <sys/personality.h> 35#include <sys/prctl.h> 36#include <sys/resource.h> 37#include <sys/stat.h> 38#include <sys/types.h> 39#include <sys/utsname.h> 40#include <sys/wait.h> 41#include <unistd.h> 42 43#include <cutils/fs.h> 44#include <cutils/multiuser.h> 45#include <cutils/sched_policy.h> 46#include <private/android_filesystem_config.h> 47#include <utils/String8.h> 48#include <selinux/android.h> 49#include <processgroup/processgroup.h> 50 51#include "core_jni_helpers.h" 52#include "JNIHelp.h" 53#include "ScopedLocalRef.h" 54#include "ScopedPrimitiveArray.h" 55#include "ScopedUtfChars.h" 56 57#include "nativebridge/native_bridge.h" 58 59namespace { 60 61using android::String8; 62 63static pid_t gSystemServerPid = 0; 64 65static const char kZygoteClassName[] = "com/android/internal/os/Zygote"; 66static jclass gZygoteClass; 67static jmethodID gCallPostForkChildHooks; 68 69// Must match values in com.android.internal.os.Zygote. 70enum MountExternalKind { 71 MOUNT_EXTERNAL_NONE = 0, 72 MOUNT_EXTERNAL_DEFAULT = 1, 73 MOUNT_EXTERNAL_READ = 2, 74 MOUNT_EXTERNAL_WRITE = 3, 75}; 76 77static void RuntimeAbort(JNIEnv* env) { 78 env->FatalError("RuntimeAbort"); 79} 80 81// This signal handler is for zygote mode, since the zygote must reap its children 82static void SigChldHandler(int /*signal_number*/) { 83 pid_t pid; 84 int status; 85 86 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { 87 // Log process-death status that we care about. In general it is 88 // not safe to call LOG(...) from a signal handler because of 89 // possible reentrancy. However, we know a priori that the 90 // current implementation of LOG() is safe to call from a SIGCHLD 91 // handler in the zygote process. If the LOG() implementation 92 // changes its locking strategy or its use of syscalls within the 93 // lazy-init critical section, its use here may become unsafe. 94 if (WIFEXITED(status)) { 95 if (WEXITSTATUS(status)) { 96 ALOGI("Process %d exited cleanly (%d)", pid, WEXITSTATUS(status)); 97 } 98 } else if (WIFSIGNALED(status)) { 99 if (WTERMSIG(status) != SIGKILL) { 100 ALOGI("Process %d exited due to signal (%d)", pid, WTERMSIG(status)); 101 } 102 if (WCOREDUMP(status)) { 103 ALOGI("Process %d dumped core.", pid); 104 } 105 } 106 107 // If the just-crashed process is the system_server, bring down zygote 108 // so that it is restarted by init and system server will be restarted 109 // from there. 110 if (pid == gSystemServerPid) { 111 ALOGE("Exit zygote because system server (%d) has terminated", pid); 112 kill(getpid(), SIGKILL); 113 } 114 } 115 116 // Note that we shouldn't consider ECHILD an error because 117 // the secondary zygote might have no children left to wait for. 118 if (pid < 0 && errno != ECHILD) { 119 ALOGW("Zygote SIGCHLD error in waitpid: %s", strerror(errno)); 120 } 121} 122 123// Configures the SIGCHLD handler for the zygote process. This is configured 124// very late, because earlier in the runtime we may fork() and exec() 125// other processes, and we want to waitpid() for those rather than 126// have them be harvested immediately. 127// 128// This ends up being called repeatedly before each fork(), but there's 129// no real harm in that. 130static void SetSigChldHandler() { 131 struct sigaction sa; 132 memset(&sa, 0, sizeof(sa)); 133 sa.sa_handler = SigChldHandler; 134 135 int err = sigaction(SIGCHLD, &sa, NULL); 136 if (err < 0) { 137 ALOGW("Error setting SIGCHLD handler: %s", strerror(errno)); 138 } 139} 140 141// Sets the SIGCHLD handler back to default behavior in zygote children. 142static void UnsetSigChldHandler() { 143 struct sigaction sa; 144 memset(&sa, 0, sizeof(sa)); 145 sa.sa_handler = SIG_DFL; 146 147 int err = sigaction(SIGCHLD, &sa, NULL); 148 if (err < 0) { 149 ALOGW("Error unsetting SIGCHLD handler: %s", strerror(errno)); 150 } 151} 152 153// Calls POSIX setgroups() using the int[] object as an argument. 154// A NULL argument is tolerated. 155static void SetGids(JNIEnv* env, jintArray javaGids) { 156 if (javaGids == NULL) { 157 return; 158 } 159 160 ScopedIntArrayRO gids(env, javaGids); 161 if (gids.get() == NULL) { 162 RuntimeAbort(env); 163 } 164 int rc = setgroups(gids.size(), reinterpret_cast<const gid_t*>(&gids[0])); 165 if (rc == -1) { 166 ALOGE("setgroups failed"); 167 RuntimeAbort(env); 168 } 169} 170 171// Sets the resource limits via setrlimit(2) for the values in the 172// two-dimensional array of integers that's passed in. The second dimension 173// contains a tuple of length 3: (resource, rlim_cur, rlim_max). NULL is 174// treated as an empty array. 175static void SetRLimits(JNIEnv* env, jobjectArray javaRlimits) { 176 if (javaRlimits == NULL) { 177 return; 178 } 179 180 rlimit rlim; 181 memset(&rlim, 0, sizeof(rlim)); 182 183 for (int i = 0; i < env->GetArrayLength(javaRlimits); ++i) { 184 ScopedLocalRef<jobject> javaRlimitObject(env, env->GetObjectArrayElement(javaRlimits, i)); 185 ScopedIntArrayRO javaRlimit(env, reinterpret_cast<jintArray>(javaRlimitObject.get())); 186 if (javaRlimit.size() != 3) { 187 ALOGE("rlimits array must have a second dimension of size 3"); 188 RuntimeAbort(env); 189 } 190 191 rlim.rlim_cur = javaRlimit[1]; 192 rlim.rlim_max = javaRlimit[2]; 193 194 int rc = setrlimit(javaRlimit[0], &rlim); 195 if (rc == -1) { 196 ALOGE("setrlimit(%d, {%ld, %ld}) failed", javaRlimit[0], rlim.rlim_cur, 197 rlim.rlim_max); 198 RuntimeAbort(env); 199 } 200 } 201} 202 203// The debug malloc library needs to know whether it's the zygote or a child. 204extern "C" int gMallocLeakZygoteChild; 205 206static void EnableKeepCapabilities(JNIEnv* env) { 207 int rc = prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); 208 if (rc == -1) { 209 ALOGE("prctl(PR_SET_KEEPCAPS) failed"); 210 RuntimeAbort(env); 211 } 212} 213 214static void DropCapabilitiesBoundingSet(JNIEnv* env) { 215 for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) { 216 int rc = prctl(PR_CAPBSET_DROP, i, 0, 0, 0); 217 if (rc == -1) { 218 if (errno == EINVAL) { 219 ALOGE("prctl(PR_CAPBSET_DROP) failed with EINVAL. Please verify " 220 "your kernel is compiled with file capabilities support"); 221 } else { 222 ALOGE("prctl(PR_CAPBSET_DROP) failed"); 223 RuntimeAbort(env); 224 } 225 } 226 } 227} 228 229static void SetCapabilities(JNIEnv* env, int64_t permitted, int64_t effective) { 230 __user_cap_header_struct capheader; 231 memset(&capheader, 0, sizeof(capheader)); 232 capheader.version = _LINUX_CAPABILITY_VERSION_3; 233 capheader.pid = 0; 234 235 __user_cap_data_struct capdata[2]; 236 memset(&capdata, 0, sizeof(capdata)); 237 capdata[0].effective = effective; 238 capdata[1].effective = effective >> 32; 239 capdata[0].permitted = permitted; 240 capdata[1].permitted = permitted >> 32; 241 242 if (capset(&capheader, &capdata[0]) == -1) { 243 ALOGE("capset(%" PRId64 ", %" PRId64 ") failed", permitted, effective); 244 RuntimeAbort(env); 245 } 246} 247 248static void SetSchedulerPolicy(JNIEnv* env) { 249 errno = -set_sched_policy(0, SP_DEFAULT); 250 if (errno != 0) { 251 ALOGE("set_sched_policy(0, SP_DEFAULT) failed"); 252 RuntimeAbort(env); 253 } 254} 255 256static int UnmountTree(const char* path) { 257 size_t path_len = strlen(path); 258 259 FILE* fp = setmntent("/proc/mounts", "r"); 260 if (fp == NULL) { 261 ALOGE("Error opening /proc/mounts: %s", strerror(errno)); 262 return -errno; 263 } 264 265 // Some volumes can be stacked on each other, so force unmount in 266 // reverse order to give us the best chance of success. 267 std::list<std::string> toUnmount; 268 mntent* mentry; 269 while ((mentry = getmntent(fp)) != NULL) { 270 if (strncmp(mentry->mnt_dir, path, path_len) == 0) { 271 toUnmount.push_front(std::string(mentry->mnt_dir)); 272 } 273 } 274 endmntent(fp); 275 276 for (auto path : toUnmount) { 277 if (umount2(path.c_str(), MNT_DETACH)) { 278 ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno)); 279 } 280 } 281 return 0; 282} 283 284// Create a private mount namespace and bind mount appropriate emulated 285// storage for the given user. 286static bool MountEmulatedStorage(uid_t uid, jint mount_mode, 287 bool force_mount_namespace) { 288 // See storage config details at http://source.android.com/tech/storage/ 289 290 // Create a second private mount namespace for our process 291 if (unshare(CLONE_NEWNS) == -1) { 292 ALOGW("Failed to unshare(): %s", strerror(errno)); 293 return false; 294 } 295 296 // Unmount storage provided by root namespace and mount requested view 297 UnmountTree("/storage"); 298 299 String8 storageSource; 300 if (mount_mode == MOUNT_EXTERNAL_DEFAULT) { 301 storageSource = "/mnt/runtime/default"; 302 } else if (mount_mode == MOUNT_EXTERNAL_READ) { 303 storageSource = "/mnt/runtime/read"; 304 } else if (mount_mode == MOUNT_EXTERNAL_WRITE) { 305 storageSource = "/mnt/runtime/write"; 306 } else { 307 // Sane default of no storage visible 308 return true; 309 } 310 if (TEMP_FAILURE_RETRY(mount(storageSource.string(), "/storage", 311 NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) { 312 ALOGW("Failed to mount %s to /storage: %s", storageSource.string(), strerror(errno)); 313 return false; 314 } 315 316 // Mount user-specific symlink helper into place 317 userid_t user_id = multiuser_get_user_id(uid); 318 const String8 userSource(String8::format("/mnt/user/%d", user_id)); 319 if (fs_prepare_dir(userSource.string(), 0751, 0, 0) == -1) { 320 return false; 321 } 322 if (TEMP_FAILURE_RETRY(mount(userSource.string(), "/storage/self", 323 NULL, MS_BIND, NULL)) == -1) { 324 ALOGW("Failed to mount %s to /storage/self: %s", userSource.string(), strerror(errno)); 325 return false; 326 } 327 328 return true; 329} 330 331static bool NeedsNoRandomizeWorkaround() { 332#if !defined(__arm__) 333 return false; 334#else 335 int major; 336 int minor; 337 struct utsname uts; 338 if (uname(&uts) == -1) { 339 return false; 340 } 341 342 if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) { 343 return false; 344 } 345 346 // Kernels before 3.4.* need the workaround. 347 return (major < 3) || ((major == 3) && (minor < 4)); 348#endif 349} 350 351// Utility to close down the Zygote socket file descriptors while 352// the child is still running as root with Zygote's privileges. Each 353// descriptor (if any) is closed via dup2(), replacing it with a valid 354// (open) descriptor to /dev/null. 355 356static void DetachDescriptors(JNIEnv* env, jintArray fdsToClose) { 357 if (!fdsToClose) { 358 return; 359 } 360 jsize count = env->GetArrayLength(fdsToClose); 361 jint *ar = env->GetIntArrayElements(fdsToClose, 0); 362 if (!ar) { 363 ALOGE("Bad fd array"); 364 RuntimeAbort(env); 365 } 366 jsize i; 367 int devnull; 368 for (i = 0; i < count; i++) { 369 devnull = open("/dev/null", O_RDWR); 370 if (devnull < 0) { 371 ALOGE("Failed to open /dev/null: %s", strerror(errno)); 372 RuntimeAbort(env); 373 continue; 374 } 375 ALOGV("Switching descriptor %d to /dev/null: %s", ar[i], strerror(errno)); 376 if (dup2(devnull, ar[i]) < 0) { 377 ALOGE("Failed dup2() on descriptor %d: %s", ar[i], strerror(errno)); 378 RuntimeAbort(env); 379 } 380 close(devnull); 381 } 382} 383 384void SetThreadName(const char* thread_name) { 385 bool hasAt = false; 386 bool hasDot = false; 387 const char* s = thread_name; 388 while (*s) { 389 if (*s == '.') { 390 hasDot = true; 391 } else if (*s == '@') { 392 hasAt = true; 393 } 394 s++; 395 } 396 const int len = s - thread_name; 397 if (len < 15 || hasAt || !hasDot) { 398 s = thread_name; 399 } else { 400 s = thread_name + len - 15; 401 } 402 // pthread_setname_np fails rather than truncating long strings. 403 char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded into bionic 404 strlcpy(buf, s, sizeof(buf)-1); 405 errno = pthread_setname_np(pthread_self(), buf); 406 if (errno != 0) { 407 ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno)); 408 } 409} 410 411#ifdef ENABLE_SCHED_BOOST 412static void SetForkLoad(bool boost) { 413 // set scheduler knob to boost forked processes 414 pid_t currentPid = getpid(); 415 // fits at most "/proc/XXXXXXX/sched_init_task_load\0" 416 char schedPath[35]; 417 snprintf(schedPath, sizeof(schedPath), "/proc/%u/sched_init_task_load", currentPid); 418 int schedBoostFile = open(schedPath, O_WRONLY); 419 if (schedBoostFile < 0) { 420 ALOGW("Unable to set zygote scheduler boost"); 421 return; 422 } 423 if (boost) { 424 write(schedBoostFile, "100\0", 4); 425 } else { 426 write(schedBoostFile, "0\0", 2); 427 } 428 close(schedBoostFile); 429} 430#endif 431 432// Utility routine to fork zygote and specialize the child process. 433static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, 434 jint debug_flags, jobjectArray javaRlimits, 435 jlong permittedCapabilities, jlong effectiveCapabilities, 436 jint mount_external, 437 jstring java_se_info, jstring java_se_name, 438 bool is_system_server, jintArray fdsToClose, 439 jstring instructionSet, jstring dataDir) { 440 SetSigChldHandler(); 441 442#ifdef ENABLE_SCHED_BOOST 443 SetForkLoad(true); 444#endif 445 446 pid_t pid = fork(); 447 448 if (pid == 0) { 449 // The child process. 450 gMallocLeakZygoteChild = 1; 451 452 // Clean up any descriptors which must be closed immediately 453 DetachDescriptors(env, fdsToClose); 454 455 // Keep capabilities across UID change, unless we're staying root. 456 if (uid != 0) { 457 EnableKeepCapabilities(env); 458 } 459 460 DropCapabilitiesBoundingSet(env); 461 462 bool use_native_bridge = !is_system_server && (instructionSet != NULL) 463 && android::NativeBridgeAvailable(); 464 if (use_native_bridge) { 465 ScopedUtfChars isa_string(env, instructionSet); 466 use_native_bridge = android::NeedsNativeBridge(isa_string.c_str()); 467 } 468 if (use_native_bridge && dataDir == NULL) { 469 // dataDir should never be null if we need to use a native bridge. 470 // In general, dataDir will never be null for normal applications. It can only happen in 471 // special cases (for isolated processes which are not associated with any app). These are 472 // launched by the framework and should not be emulated anyway. 473 use_native_bridge = false; 474 ALOGW("Native bridge will not be used because dataDir == NULL."); 475 } 476 477 if (!MountEmulatedStorage(uid, mount_external, use_native_bridge)) { 478 ALOGW("Failed to mount emulated storage: %s", strerror(errno)); 479 if (errno == ENOTCONN || errno == EROFS) { 480 // When device is actively encrypting, we get ENOTCONN here 481 // since FUSE was mounted before the framework restarted. 482 // When encrypted device is booting, we get EROFS since 483 // FUSE hasn't been created yet by init. 484 // In either case, continue without external storage. 485 } else { 486 ALOGE("Cannot continue without emulated storage"); 487 RuntimeAbort(env); 488 } 489 } 490 491 if (!is_system_server) { 492 int rc = createProcessGroup(uid, getpid()); 493 if (rc != 0) { 494 if (rc == -EROFS) { 495 ALOGW("createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?"); 496 } else { 497 ALOGE("createProcessGroup(%d, %d) failed: %s", uid, pid, strerror(-rc)); 498 } 499 } 500 } 501 502 SetGids(env, javaGids); 503 504 SetRLimits(env, javaRlimits); 505 506 if (use_native_bridge) { 507 ScopedUtfChars isa_string(env, instructionSet); 508 ScopedUtfChars data_dir(env, dataDir); 509 android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str()); 510 } 511 512 int rc = setresgid(gid, gid, gid); 513 if (rc == -1) { 514 ALOGE("setresgid(%d) failed: %s", gid, strerror(errno)); 515 RuntimeAbort(env); 516 } 517 518 rc = setresuid(uid, uid, uid); 519 if (rc == -1) { 520 ALOGE("setresuid(%d) failed: %s", uid, strerror(errno)); 521 RuntimeAbort(env); 522 } 523 524 if (NeedsNoRandomizeWorkaround()) { 525 // Work around ARM kernel ASLR lossage (http://b/5817320). 526 int old_personality = personality(0xffffffff); 527 int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE); 528 if (new_personality == -1) { 529 ALOGW("personality(%d) failed: %s", new_personality, strerror(errno)); 530 } 531 } 532 533 SetCapabilities(env, permittedCapabilities, effectiveCapabilities); 534 535 SetSchedulerPolicy(env); 536 537 const char* se_info_c_str = NULL; 538 ScopedUtfChars* se_info = NULL; 539 if (java_se_info != NULL) { 540 se_info = new ScopedUtfChars(env, java_se_info); 541 se_info_c_str = se_info->c_str(); 542 if (se_info_c_str == NULL) { 543 ALOGE("se_info_c_str == NULL"); 544 RuntimeAbort(env); 545 } 546 } 547 const char* se_name_c_str = NULL; 548 ScopedUtfChars* se_name = NULL; 549 if (java_se_name != NULL) { 550 se_name = new ScopedUtfChars(env, java_se_name); 551 se_name_c_str = se_name->c_str(); 552 if (se_name_c_str == NULL) { 553 ALOGE("se_name_c_str == NULL"); 554 RuntimeAbort(env); 555 } 556 } 557 rc = selinux_android_setcontext(uid, is_system_server, se_info_c_str, se_name_c_str); 558 if (rc == -1) { 559 ALOGE("selinux_android_setcontext(%d, %d, \"%s\", \"%s\") failed", uid, 560 is_system_server, se_info_c_str, se_name_c_str); 561 RuntimeAbort(env); 562 } 563 564 // Make it easier to debug audit logs by setting the main thread's name to the 565 // nice name rather than "app_process". 566 if (se_info_c_str == NULL && is_system_server) { 567 se_name_c_str = "system_server"; 568 } 569 if (se_info_c_str != NULL) { 570 SetThreadName(se_name_c_str); 571 } 572 573 delete se_info; 574 delete se_name; 575 576 UnsetSigChldHandler(); 577 578 env->CallStaticVoidMethod(gZygoteClass, gCallPostForkChildHooks, debug_flags, 579 is_system_server ? NULL : instructionSet); 580 if (env->ExceptionCheck()) { 581 ALOGE("Error calling post fork hooks."); 582 RuntimeAbort(env); 583 } 584 } else if (pid > 0) { 585 // the parent process 586 587#ifdef ENABLE_SCHED_BOOST 588 // unset scheduler knob 589 SetForkLoad(false); 590#endif 591 592 } 593 return pid; 594} 595} // anonymous namespace 596 597namespace android { 598 599static jint com_android_internal_os_Zygote_nativeForkAndSpecialize( 600 JNIEnv* env, jclass, jint uid, jint gid, jintArray gids, 601 jint debug_flags, jobjectArray rlimits, 602 jint mount_external, jstring se_info, jstring se_name, 603 jintArray fdsToClose, jstring instructionSet, jstring appDataDir) { 604 // Grant CAP_WAKE_ALARM to the Bluetooth process. 605 jlong capabilities = 0; 606 if (uid == AID_BLUETOOTH) { 607 capabilities |= (1LL << CAP_WAKE_ALARM); 608 } 609 610 return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, 611 rlimits, capabilities, capabilities, mount_external, se_info, 612 se_name, false, fdsToClose, instructionSet, appDataDir); 613} 614 615static jint com_android_internal_os_Zygote_nativeForkSystemServer( 616 JNIEnv* env, jclass, uid_t uid, gid_t gid, jintArray gids, 617 jint debug_flags, jobjectArray rlimits, jlong permittedCapabilities, 618 jlong effectiveCapabilities) { 619 pid_t pid = ForkAndSpecializeCommon(env, uid, gid, gids, 620 debug_flags, rlimits, 621 permittedCapabilities, effectiveCapabilities, 622 MOUNT_EXTERNAL_DEFAULT, NULL, NULL, true, NULL, 623 NULL, NULL); 624 if (pid > 0) { 625 // The zygote process checks whether the child process has died or not. 626 ALOGI("System server process %d has been created", pid); 627 gSystemServerPid = pid; 628 // There is a slight window that the system server process has crashed 629 // but it went unnoticed because we haven't published its pid yet. So 630 // we recheck here just to make sure that all is well. 631 int status; 632 if (waitpid(pid, &status, WNOHANG) == pid) { 633 ALOGE("System server process %d has died. Restarting Zygote!", pid); 634 RuntimeAbort(env); 635 } 636 } 637 return pid; 638} 639 640static JNINativeMethod gMethods[] = { 641 { "nativeForkAndSpecialize", 642 "(II[II[[IILjava/lang/String;Ljava/lang/String;[ILjava/lang/String;Ljava/lang/String;)I", 643 (void *) com_android_internal_os_Zygote_nativeForkAndSpecialize }, 644 { "nativeForkSystemServer", "(II[II[[IJJ)I", 645 (void *) com_android_internal_os_Zygote_nativeForkSystemServer } 646}; 647 648int register_com_android_internal_os_Zygote(JNIEnv* env) { 649 gZygoteClass = MakeGlobalRefOrDie(env, FindClassOrDie(env, kZygoteClassName)); 650 gCallPostForkChildHooks = GetStaticMethodIDOrDie(env, gZygoteClass, "callPostForkChildHooks", 651 "(ILjava/lang/String;)V"); 652 653 return RegisterMethodsOrDie(env, "com/android/internal/os/Zygote", gMethods, NELEM(gMethods)); 654} 655} // namespace android 656 657