Android startup Research (1)

Source: Internet
Author: User

I haven't studied this file carefully yet, but a netizen suddenly asked me a question, and I still know about it.

An important process in android system applications is zygote. All java application processes are derived from zygote. The role of zygote is "son ". For more information about how an app comes out, see my previous article-Android app initialization and form event distribution.

First, you need to understand the basic knowledge of the initialization language:

A service is a program that is started during initialization and restarted upon exit (optional ). Services are as follows:

Service <name> <pathname> [<argument>] *
<Option>
<Option>
Options is an option. For more information, see linux service commands.

The zygote process is started through this file after linux kernel startup. For details, see the section in init. rc:

Service zygote/system/bin/app_process-Xzygote/system/bin -- zygote -- start-system-server
Socket zygote stream 666
Onrestart write/sys/android_power/request_state wake
Onrestart write/sys/power/state on

A piece of analysis code:

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

The binfile path of the startup service name zygote./system/bin/app_process process is followed by the startup parameter-Xzygote/system/bin -- zygote -- start-system-server. What is the function of this parameter? Check the code app_main.cpp.

If (I <argc ){
Arg = argv [I ++];
If (0 = strcmp ("-- zygote", arg )){
Bool startSystemServer = (I <argc )?
Strcmp (argv [I], "-- start-system-server") = 0: false;
SetArgv0 (argv0, "zygote ");
Set_process_name ("zygote ");
Runtime. start ("com. android. internal. OS. ZygoteInit ",
StartSystemServer );
} Else {
Set_process_name (argv0 );

Runtime. mClassName = arg;

// Remainder of args get passed to startup class main ()
Runtime. mArgC = argc-I;
Runtime. mArgV = argv + I;

LOGV ("App process is starting with pid = % d, class = % s./n ",
Getpid (), runtime. getClassName ());
Runtime. start ();
}
}

-The significance of Xzygote is to set gDvm. zygote = true in jvm. For the specific role of this parameter, read the code. The process is androidRuntime-> start () call ---> JNI_CreateJavaVM () call ----> dvmStartup () (davilin VM initialization) call ----> dvmProcessOptions ().

/System/bin: Maybe the path of the system application. If you see it, let me know.

Onrestart write/sys/android_power/request_state wake:

If the service is restarted, open the/sys/android_power/request_state file and write the wake string.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.