我的进阶曲线之七

来源:互联网 发布:安卓中文编程软件 编辑:程序博客网 时间:2024/05/22 03:12

init.rc

service zygote/system/bin/app_process -Xzygote /system/bin --zygote --start-system-server


app_main.cpp

    if (zygote) {

      runtime.start("com.android.internal.os.ZygoteInit",

                startSystemServer  "start-system-server" :"");

需要说明下这个:runtime.start 这个会在创建AndroidRuntime实例的过程中,启动android虚拟机。


ZygoteInit.java

/**

 * Startup class for the zygote process.

*/

public class ZygoteInit {

            if(argv[1].equals("start-system-server")) {

                startSystemServer();


ZygoteInit.java

/**

  * Prepare the arguments and fork for thesystem server process.

 */

private static booleanstartSystemServer()

 

           "com.android.server.SystemServer",

            /* Request to fork the systemserver process */

            pid = Zygote.forkSystemServer(


SystemServer.java

public class SystemServer {

private static native voidnativeInit();


com_android_server_SystemServer.cpp

{ "nativeInit","()V", (void*) android_server_SystemServer_nativeInit },

 

static voidandroid_server_SystemServer_nativeInit(JNIEnv* env, jobject clazz) {

   char propBuf[PROPERTY_VALUE_MAX];

   property_get("system_init.startsensorservice",propBuf, "1");

*system_server 进程名 SystemServer 类名

0 0