Java虚拟机启动成功后,开始系统初始化。系统初始的第一步是用JNI方式实现的,对应java代码为
(frameworks/base/services/java/com/android/server/SystemServer.java) init1(Native)函数,对应的JNI C++代码为(frameworks/base/core/jni/server/com_android_server_SystemServer.cpp),而实现的C++代码为
(frameworks/base/cmds/system_server/library/ System_init.cpp) 中的system_init()函数
下面是对应接口注册方法:
/*
* JNI registration. (frameworks/base/services/jni/com_android_server_systemserver.cpp)
*/
static void android_server_SystemServer_init1(JNIEnv* env, jobject clazz)
{
system_init();
}
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{ "init1", "([Ljava/lang/String;)V", (void*) android_server_SystemServer_init1 },
};
int register_android_server_SystemServer(JNIEnv* env)
{
return jniRegisterNativeMethods(env, "com/android/server/SystemServer",
gMethods, NELEM(gMethods));
}