diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-05-16 20:45:48 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-05-16 20:55:41 -0700 |
commit | 7916ac65dc492e4e1431879875c77d7121fbf82e (patch) | |
tree | a673e4cc163ea0e1d27d5a38fd2d37003812e37d /cmds/am | |
parent | 8f3dbe1c377e64584c3ec10edf664fb278648109 (diff) | |
download | frameworks_base-7916ac65dc492e4e1431879875c77d7121fbf82e.zip frameworks_base-7916ac65dc492e4e1431879875c77d7121fbf82e.tar.gz frameworks_base-7916ac65dc492e4e1431879875c77d7121fbf82e.tar.bz2 |
Add new command line option to change global screen size.
For example:
adb shell am display-size 1024x600
Change-Id: I5df462acd3323bdaaaefa3126faea7dd8595b726
Diffstat (limited to 'cmds/am')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 8a9144c..38cacdd 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -25,6 +25,7 @@ import android.app.IActivityManager; import android.app.IInstrumentationWatcher; import android.app.Instrumentation; import android.content.ComponentName; +import android.content.Context; import android.content.IIntentReceiver; import android.content.Intent; import android.net.Uri; @@ -109,6 +110,8 @@ public class Am { runMonitor(); } else if (op.equals("screen-compat")) { runScreenCompat(); + } else if (op.equals("display-size")) { + runDisplaySize(); } else { throw new IllegalArgumentException("Unknown command: " + op); } @@ -804,6 +807,53 @@ public class Am { } while (packageName != null); } + private void runDisplaySize() throws Exception { + String size = nextArgRequired(); + int m, n; + if ("reset".equals(size)) { + m = n = -1; + } else { + int div = size.indexOf('x'); + if (div <= 0 || div >= (size.length()-1)) { + System.err.println("Error: bad size " + size); + showUsage(); + return; + } + String mstr = size.substring(0, div); + String nstr = size.substring(div+1); + try { + m = Integer.parseInt(mstr); + n = Integer.parseInt(nstr); + } catch (NumberFormatException e) { + System.err.println("Error: bad number " + e); + showUsage(); + return; + } + } + + if (m < n) { + int tmp = m; + m = n; + n = tmp; + } + + IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService( + Context.WINDOW_SERVICE)); + if (wm == null) { + System.err.println(NO_SYSTEM_ERROR_CODE); + throw new AndroidException("Can't connect to window manager; is the system running?"); + } + + try { + if (m >= 0 && n >= 0) { + wm.setForcedDisplaySize(m, n); + } else { + wm.clearForcedDisplaySize(); + } + } catch (RemoteException e) { + } + } + private class IntentReceiver extends IIntentReceiver.Stub { private boolean mFinished = false; @@ -986,6 +1036,8 @@ public class Am { "\n" + " control screen compatibility: am screen-compat [on|off] [package]\n" + "\n" + + " override display size: am display-size [reset|MxN]\n" + + "\n" + " <INTENT> specifications include these flags:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + " [-c <CATEGORY> [-c <CATEGORY>] ...]\n" + |