summaryrefslogtreecommitdiffstats
path: root/cmds/wm
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2015-04-15 19:02:36 -0700
committerJeff Brown <jeffbrown@google.com>2015-04-15 19:02:36 -0700
commitd46747a1c64b6ca3282e8841833980ab91829436 (patch)
treefeca484f9f10ee91399a12b41a524fb7f20a3eb5 /cmds/wm
parent10acf6d3efde60977d2d2e82b90c53d722d9d357 (diff)
downloadframeworks_base-d46747a1c64b6ca3282e8841833980ab91829436.zip
frameworks_base-d46747a1c64b6ca3282e8841833980ab91829436.tar.gz
frameworks_base-d46747a1c64b6ca3282e8841833980ab91829436.tar.bz2
Add support for disabling display scaling for development.
Added two new options to the wm command. 1. Set the screen size based on dips rather than pixels using the current screen density. eg. adb shell wm size 320dpx320dp 2. Disable automatic scaling of the contents of the display. When combined with the previous command, this is useful for seeing how the UI would behave if the screen remained at its current density but changed physical size. eg. adb shell wm scaling off Bug: 19899223 Change-Id: I545f893ba4861494e995cf0457ebeba1050d28dc
Diffstat (limited to 'cmds/wm')
-rw-r--r--cmds/wm/src/com/android/commands/wm/Wm.java46
1 files changed, 42 insertions, 4 deletions
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java
index 815a0ac..64f023f 100644
--- a/cmds/wm/src/com/android/commands/wm/Wm.java
+++ b/cmds/wm/src/com/android/commands/wm/Wm.java
@@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.AndroidException;
+import android.util.DisplayMetrics;
import android.view.Display;
import android.view.IWindowManager;
import com.android.internal.os.BaseCommand;
@@ -45,21 +46,27 @@ public class Wm extends BaseCommand {
(new Wm()).run(args);
}
+ @Override
public void onShowUsage(PrintStream out) {
out.println(
"usage: wm [subcommand] [options]\n" +
- " wm size [reset|WxH]\n" +
+ " wm size [reset|WxH|WdpxHdp]\n" +
" wm density [reset|DENSITY]\n" +
" wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]\n" +
+ " wm scaling [off|auto]\n" +
"\n" +
"wm size: return or override display size.\n" +
+ " width and height in pixels unless suffixed with 'dp'.\n" +
"\n" +
"wm density: override display density.\n" +
"\n" +
- "wm overscan: set overscan area for display.\n"
+ "wm overscan: set overscan area for display.\n" +
+ "\n" +
+ "wm scaling: set display scaling mode.\n"
);
}
+ @Override
public void onRun() throws Exception {
mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
Context.WINDOW_SERVICE));
@@ -76,6 +83,8 @@ public class Wm extends BaseCommand {
runDisplayDensity();
} else if (op.equals("overscan")) {
runDisplayOverscan();
+ } else if (op.equals("scaling")) {
+ runDisplayScaling();
} else {
showError("Error: unknown command '" + op + "'");
return;
@@ -85,6 +94,7 @@ public class Wm extends BaseCommand {
private void runDisplaySize() throws Exception {
String size = nextArg();
int w, h;
+ boolean scale = true;
if (size == null) {
Point initialSize = new Point();
Point baseSize = new Point();
@@ -109,8 +119,8 @@ public class Wm extends BaseCommand {
String wstr = size.substring(0, div);
String hstr = size.substring(div+1);
try {
- w = Integer.parseInt(wstr);
- h = Integer.parseInt(hstr);
+ w = parseDimension(wstr);
+ h = parseDimension(hstr);
} catch (NumberFormatException e) {
System.err.println("Error: bad number " + e);
return;
@@ -193,4 +203,32 @@ public class Wm extends BaseCommand {
} catch (RemoteException e) {
}
}
+
+ private void runDisplayScaling() throws Exception {
+ String scalingStr = nextArgRequired();
+ if ("auto".equals(scalingStr)) {
+ mWm.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 0);
+ } else if ("off".equals(scalingStr)) {
+ mWm.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 1);
+ } else {
+ System.err.println("Error: scaling must be 'auto' or 'off'");
+ }
+ }
+
+ private int parseDimension(String s) throws NumberFormatException {
+ if (s.endsWith("px")) {
+ return Integer.parseInt(s.substring(0, s.length() - 2));
+ }
+ if (s.endsWith("dp")) {
+ int density;
+ try {
+ density = mWm.getBaseDisplayDensity(Display.DEFAULT_DISPLAY);
+ } catch (RemoteException e) {
+ density = DisplayMetrics.DENSITY_DEFAULT;
+ }
+ return Integer.parseInt(s.substring(0, s.length() - 2)) * density /
+ DisplayMetrics.DENSITY_DEFAULT;
+ }
+ return Integer.parseInt(s);
+ }
}