After the state is changed to kPreInitialized, the creation of the new Android application will continue in the ForkAndSpecializeCommon function. At the end of this function, it calls a callPostForkChildHooks registered function through a global variable, gCallPostForkChildHooks. The call stack will eventually go to a ZygoteHooks_nativePostForkChild function, which is the JNI implementation of the postForkChild Java method. The postForkChild function is called by Zygote in the child process after every fork. The following table is a summary of the call stack:
Function |
Class |
Language |
ForkAndSpecializeCommon |
C++ |
|
gCallPostForkChildHooks |
C++ |
|
callPostForkChildHooks |
Zygote |
Java |
postForkChild ... |