From 69acb6b746c82f88607b3365795ebb3279188eed Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Fri, 16 Apr 2010 12:52:47 -0700 Subject: [PATCH] Unify am startservice commands. This replaces the implementation with an equivalent one. Change-Id: I1343ddee9414a67906cd426b8381ddbace873894 --- cmds/am/src/com/android/commands/am/Am.java | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 3566caf8d3221..13e6d5c478443 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -88,7 +88,7 @@ public class Am { if (op.equals("start")) { runStart(); - } else if (op.equals("start-service")) { + } else if (op.equals("startservice")) { runStartService(); } else if (op.equals("instrument")) { runInstrument(); @@ -181,6 +181,15 @@ public class Am { return intent; } + private void runStartService() throws Exception { + Intent intent = makeIntent(); + System.out.println("Starting service: " + intent); + ComponentName cn = mAm.startService(null, intent, intent.getType()); + if (cn == null) { + System.err.println("Error: Not found; no service started."); + } + } + private void runStart() throws Exception { Intent intent = makeIntent(); System.out.println("Starting: " + intent); @@ -240,19 +249,6 @@ public class Am { } } - private void runStartService() throws Exception { - Intent intent = makeIntent(); - - if (intent != null) { - System.out.println("Starting: " + intent); - try { - mAm.startService(null, intent, intent.getType()); - } catch (Exception e) { - System.err.println("Error: " + e); - } - } - } - private void sendBroadcast() throws Exception { Intent intent = makeIntent(); IntentReceiver receiver = new IntentReceiver(); @@ -507,6 +503,8 @@ public class Am { " start an Activity: am start [-D] \n" + " -D: enable debugging\n" + "\n" + + " start a Service: am startservice \n" + + "\n" + " send a broadcast Intent: am broadcast \n" + "\n" + " start an Instrumentation: am instrument [flags] \n" +