*/
int AndroidRuntime::addVmArguments(int argc, const char* const argv[])
{
int i;
for (i = 0; i < argc; i ++) {
if (argv[i][0] != '-') {
return i;
}
if (argv[i][1] == '-' && argv[i][2] == 0) {
return i + 1;
}
JavaVMOption opt;
memset(&opt, 0, sizeof(opt));
opt.optionString = (char*)argv[i];
mOptions.add(opt);
}
return i;
}
int main(int argc, char* const argv[])
{
// zygote call parameters
// /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
// These are global variables in ProcessState.cpp
mArgC = argc;
mArgV = argv;
mArgLen = 0;
for (int i = 0; i < argc; i ++) {
mArgLen += strlen(argv[i]) + 1;
}
// 去除末尾的空格
mArgLen--;
AppRuntime runtime;
const char* argv0 = argv[0];
// Process command line arguments
// ignore argv[0]
argc --;
argv ++;
// Everything up tp '--' or first non '-' arg goes to the vm
int i = runtime.addVmArguments(argc, argv);
// Parse runtime arguments. Stop at first unrecognized option.
bool zygote = false;
bool startSystemServer = false;
bool application = false;
const char* parentDir = NULL;
const char* niceName = NULL;
const char* className = NULL;
while (i < argc) {
const char* arg = argv[i ++];
if (!parentDir) {