diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-04-04 18:50:23 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2013-04-08 13:08:37 -0700 |
commit | 79f7ec70ebd5758ce54fd5b6fcd60fd27457cba6 (patch) | |
tree | 6bc7542adfb792659a153a5000fb94a3ed6abb6a /cmds/wm/src/com/android | |
parent | bab9687e6473072d6ff4f7ea5a7b21bcfbf95744 (diff) | |
download | frameworks_base-79f7ec70ebd5758ce54fd5b6fcd60fd27457cba6.zip frameworks_base-79f7ec70ebd5758ce54fd5b6fcd60fd27457cba6.tar.gz frameworks_base-79f7ec70ebd5758ce54fd5b6fcd60fd27457cba6.tar.bz2 |
Have audio service clean up new receivers in crashing processes.
The new media button receiver with only a pending intent (no
component name) could be left hanging if the process that
registered it went away. These semantically need to be tied
to the calling process's lifetime; we now clean them up when
the calling process goes away.
Also added some additional cleanup of media button receivers
when packages change (updated, cleared).
And on top of that, a new "media" command for doing media
things. Currently lets you send media keys and monitor
remote display data.
Oh and finally added a new BaseCommand base class for
implementing these command line utilities.
Change-Id: Iba1d56f10bab1eec4a94a7bb1d1c2ae614c8bcf5
Diffstat (limited to 'cmds/wm/src/com/android')
-rw-r--r-- | cmds/wm/src/com/android/commands/wm/Wm.java | 114 |
1 files changed, 22 insertions, 92 deletions
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java index 31eba96..815a0ac 100644 --- a/cmds/wm/src/com/android/commands/wm/Wm.java +++ b/cmds/wm/src/com/android/commands/wm/Wm.java @@ -26,21 +26,15 @@ import android.os.ServiceManager; import android.util.AndroidException; import android.view.Display; import android.view.IWindowManager; +import com.android.internal.os.BaseCommand; +import java.io.PrintStream; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class Wm { +public class Wm extends BaseCommand { private IWindowManager mWm; - private String[] mArgs; - private int mNextArg; - private String mCurArgData; - - // These are magic strings understood by the Eclipse plugin. - private static final String FATAL_ERROR_CODE = "Error type 1"; - private static final String NO_SYSTEM_ERROR_CODE = "Error type 2"; - private static final String NO_CLASS_ERROR_CODE = "Error type 3"; /** * Command-line entry point. @@ -48,23 +42,25 @@ public class Wm { * @param args The command-line arguments */ public static void main(String[] args) { - try { - (new Wm()).run(args); - } catch (IllegalArgumentException e) { - showUsage(); - System.err.println("Error: " + e.getMessage()); - } catch (Exception e) { - e.printStackTrace(System.err); - System.exit(1); - } + (new Wm()).run(args); } - private void run(String[] args) throws Exception { - if (args.length < 1) { - showUsage(); - return; - } + public void onShowUsage(PrintStream out) { + out.println( + "usage: wm [subcommand] [options]\n" + + " wm size [reset|WxH]\n" + + " wm density [reset|DENSITY]\n" + + " wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]\n" + + "\n" + + "wm size: return or override display size.\n" + + "\n" + + "wm density: override display density.\n" + + "\n" + + "wm overscan: set overscan area for display.\n" + ); + } + public void onRun() throws Exception { mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService( Context.WINDOW_SERVICE)); if (mWm == null) { @@ -72,9 +68,7 @@ public class Wm { throw new AndroidException("Can't connect to window manager; is the system running?"); } - mArgs = args; - String op = args[0]; - mNextArg = 1; + String op = nextArgRequired(); if (op.equals("size")) { runDisplaySize(); @@ -83,7 +77,8 @@ public class Wm { } else if (op.equals("overscan")) { runDisplayOverscan(); } else { - throw new IllegalArgumentException("Unknown command: " + op); + showError("Error: unknown command '" + op + "'"); + return; } } @@ -198,69 +193,4 @@ public class Wm { } catch (RemoteException e) { } } - - private String nextOption() { - if (mCurArgData != null) { - String prev = mArgs[mNextArg - 1]; - throw new IllegalArgumentException("No argument expected after \"" + prev + "\""); - } - if (mNextArg >= mArgs.length) { - return null; - } - String arg = mArgs[mNextArg]; - if (!arg.startsWith("-")) { - return null; - } - mNextArg++; - if (arg.equals("--")) { - return null; - } - if (arg.length() > 1 && arg.charAt(1) != '-') { - if (arg.length() > 2) { - mCurArgData = arg.substring(2); - return arg.substring(0, 2); - } else { - mCurArgData = null; - return arg; - } - } - mCurArgData = null; - return arg; - } - - private String nextArg() { - if (mCurArgData != null) { - String arg = mCurArgData; - mCurArgData = null; - return arg; - } else if (mNextArg < mArgs.length) { - return mArgs[mNextArg++]; - } else { - return null; - } - } - - private String nextArgRequired() { - String arg = nextArg(); - if (arg == null) { - String prev = mArgs[mNextArg - 1]; - throw new IllegalArgumentException("Argument expected after \"" + prev + "\""); - } - return arg; - } - - private static void showUsage() { - System.err.println( - "usage: wm [subcommand] [options]\n" + - " wm size [reset|WxH]\n" + - " wm density [reset|DENSITY]\n" + - " wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]\n" + - "\n" + - "wm size: return or override display size.\n" + - "\n" + - "wm density: override display density.\n" + - "\n" + - "wm overscan: set overscan area for display.\n" - ); - } } |