summaryrefslogtreecommitdiffstats
path: root/cmds/app_process
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-05-16 17:08:42 -0700
committerJeff Brown <jeffbrown@google.com>2011-05-24 12:01:25 -0700
commitebed7d6e35f7f960e6e6add2b8ab7c7a31a511c3 (patch)
treeae346479a6c069a3a57acecb18a0b0a563325e3f /cmds/app_process
parentcbc38e74f028d9e337eba0f3ed7c435310cc10c2 (diff)
downloadframeworks_base-ebed7d6e35f7f960e6e6add2b8ab7c7a31a511c3.zip
frameworks_base-ebed7d6e35f7f960e6e6add2b8ab7c7a31a511c3.tar.gz
frameworks_base-ebed7d6e35f7f960e6e6add2b8ab7c7a31a511c3.tar.bz2
Support wrapping app processes to inject debug instrumentation.
Bug: 4437846 Change-Id: I4552501c693716b14714afb5c5248edaca9547ab
Diffstat (limited to 'cmds/app_process')
-rw-r--r--cmds/app_process/app_main.cpp71
1 files changed, 41 insertions, 30 deletions
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 371268f..152a7cb 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -149,10 +149,7 @@ int main(int argc, const char* const argv[])
mArgLen--;
AppRuntime runtime;
- const char *arg;
- const char *argv0;
-
- argv0 = argv[0];
+ const char* argv0 = argv[0];
// Process command line arguments
// ignore argv[0]
@@ -163,39 +160,53 @@ int main(int argc, const char* const argv[])
int i = runtime.addVmArguments(argc, argv);
- // Next arg is parent directory
- if (i < argc) {
- runtime.mParentDir = argv[i++];
- }
-
- // Next arg is startup classname or "--zygote"
- 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);
+ // 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) {
+ parentDir = arg;
+ } else if (strcmp(arg, "--zygote") == 0) {
+ zygote = true;
+ niceName = "zygote";
+ } else if (strcmp(arg, "--start-system-server") == 0) {
+ startSystemServer = true;
+ } else if (strcmp(arg, "--application") == 0) {
+ application = true;
+ } else if (strncmp(arg, "--nice-name=", 12) == 0) {
+ niceName = arg + 12;
} else {
- set_process_name(argv0);
-
- runtime.mClassName = arg;
+ className = arg;
+ break;
+ }
+ }
- // Remainder of args get passed to startup class main()
- runtime.mArgC = argc-i;
- runtime.mArgV = argv+i;
+ if (niceName && *niceName) {
+ setArgv0(argv0, niceName);
+ set_process_name(niceName);
+ }
- LOGV("App process is starting with pid=%d, class=%s.\n",
- getpid(), runtime.getClassName());
- runtime.start();
- }
+ runtime.mParentDir = parentDir;
+
+ if (zygote) {
+ runtime.start("com.android.internal.os.ZygoteInit",
+ startSystemServer ? "start-system-server" : "");
+ } else if (className) {
+ // Remainder of args get passed to startup class main()
+ runtime.mClassName = className;
+ runtime.mArgC = argc - i;
+ runtime.mArgV = argv + i;
+ runtime.start("com.android.internal.os.RuntimeInit",
+ application ? "application" : "tool");
} else {
fprintf(stderr, "Error: no class name or --zygote supplied.\n");
app_usage();
LOG_ALWAYS_FATAL("app_process: no class name or --zygote supplied.");
return 10;
}
-
}