diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 20:00:43 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 20:00:43 -0800 |
commit | f5b4b98fada53d91c4c2ebeb5a1d33ccc95c94d2 (patch) | |
tree | 3a24d2250b24d928cd5b67936affc4f0ac3b599b /cmds | |
parent | 53b404521227d30353f0f2421458103dff903626 (diff) | |
download | frameworks_base-f5b4b98fada53d91c4c2ebeb5a1d33ccc95c94d2.zip frameworks_base-f5b4b98fada53d91c4c2ebeb5a1d33ccc95c94d2.tar.gz frameworks_base-f5b4b98fada53d91c4c2ebeb5a1d33ccc95c94d2.tar.bz2 |
auto import from //depot/cupcake/@136745
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index b86d40a..6d4b455 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -75,6 +75,8 @@ public class Am { runInstrument(); } else if (op.equals("broadcast")) { sendBroadcast(); + } else if (op.equals("profile")) { + runProfile(); } else { System.err.println("Error: Unknown command: " + op); showUsage(); @@ -423,6 +425,49 @@ public class Am { } } + private void runProfile() { + String profileFile = null; + boolean start = false; + + String process = nextArg(); + if (process == null) { + System.err.println("Error: No profile process supplied"); + showUsage(); + return; + } + + String cmd = nextArg(); + if ("start".equals(cmd)) { + start = true; + profileFile = nextArg(); + if (profileFile == null) { + System.err.println("Error: No profile file path supplied"); + showUsage(); + return; + } + } else if (!"stop".equals(cmd)) { + System.err.println("Error: Profile command " + cmd + " not valid"); + showUsage(); + return; + } + + try { + if (!mAm.profileControl(process, start, profileFile)) { + System.out.println("PROFILE FAILED on process " + process); + return; + } + } catch (IllegalArgumentException e) { + System.out.println("PROFILE FAILED: " + e.getMessage()); + return; + } catch (IllegalStateException e) { + System.out.println("PROFILE FAILED: " + e.getMessage()); + return; + } catch (RemoteException e) { + System.out.println("PROFILE FAILED: activity manager gone"); + return; + } + } + private String nextOption() { if (mNextArg >= mArgs.length) { return null; @@ -470,11 +515,12 @@ public class Am { } private void showUsage() { - System.err.println("usage: am [start|broadcast|instrument]"); + System.err.println("usage: am [start|broadcast|instrument|profile]"); System.err.println(" am start -D INTENT"); System.err.println(" am broadcast INTENT"); System.err.println(" am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]"); System.err.println(" [-w] <COMPONENT> "); + System.err.println(" am profile <PROCESS> [start <PROF_FILE>|stop]"); System.err.println(""); System.err.println(" INTENT is described with:"); System.err.println(" [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]"); |