Loading services/core/java/com/android/server/wm/WindowManagerService.java +3 −15 Original line number Diff line number Diff line Loading @@ -5069,9 +5069,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5104,9 +5102,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5186,9 +5182,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5235,9 +5229,6 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final int targetUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, true, "setForcedDisplayDensityForUser", Loading Loading @@ -5266,9 +5257,6 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final int callingUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, true, "clearForcedDisplayDensityForUser", Loading services/core/java/com/android/server/wm/WindowManagerShellCommand.java +75 −43 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.os.Build.IS_USER; import android.graphics.Point; import android.graphics.Rect; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ShellCommand; import android.os.UserHandle; Loading @@ -28,10 +27,6 @@ import android.util.DisplayMetrics; import android.view.Display; import android.view.IWindowManager; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; Loading Loading @@ -87,21 +82,48 @@ public class WindowManagerShellCommand extends ShellCommand { return -1; } private int runDisplaySize(PrintWriter pw) throws RemoteException { String size = getNextArg(); int w, h; if (size == null) { Point initialSize = new Point(); Point baseSize = new Point(); private int getDisplayId(String opt) { int displayId = Display.DEFAULT_DISPLAY; String option = "-d".equals(opt) ? opt : getNextOption(); if (option != null && "-d".equals(option)) { try { mInterface.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize); mInterface.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize); displayId = Integer.parseInt(getNextArgRequired()); } catch (NumberFormatException e) { getErrPrintWriter().println("Error: bad number " + e); } catch (IllegalArgumentException e) { getErrPrintWriter().println("Error: " + e); } } return displayId; } private void printInitialDisplaySize(PrintWriter pw , int displayId) { final Point initialSize = new Point(); final Point baseSize = new Point(); try { mInterface.getInitialDisplaySize(displayId, initialSize); mInterface.getBaseDisplaySize(displayId, baseSize); pw.println("Physical size: " + initialSize.x + "x" + initialSize.y); if (!initialSize.equals(baseSize)) { pw.println("Override size: " + baseSize.x + "x" + baseSize.y); } } catch (RemoteException e) { // Can't call getInitialDisplaySize() on IWindowManager or // Can't call getBaseDisplaySize() on IWindowManager pw.println("Remote exception: " + e); } } private int runDisplaySize(PrintWriter pw) throws RemoteException { String size = getNextArg(); int w, h; final int displayId = getDisplayId(size); if (size == null) { printInitialDisplaySize(pw, displayId); return 0; } else if ("-d".equals(size)) { printInitialDisplaySize(pw, displayId); return 0; } else if ("reset".equals(size)) { w = h = -1; Loading @@ -114,8 +136,8 @@ public class WindowManagerShellCommand extends ShellCommand { String wstr = size.substring(0, div); String hstr = size.substring(div+1); try { w = parseDimension(wstr); h = parseDimension(hstr); w = parseDimension(wstr, displayId); h = parseDimension(hstr, displayId); } catch (NumberFormatException e) { getErrPrintWriter().println("Error: bad number " + e); return -1; Loading @@ -123,27 +145,38 @@ public class WindowManagerShellCommand extends ShellCommand { } if (w >= 0 && h >= 0) { // TODO(multidisplay): For now Configuration only applies to main screen. mInterface.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h); mInterface.setForcedDisplaySize(displayId, w, h); } else { mInterface.clearForcedDisplaySize(Display.DEFAULT_DISPLAY); mInterface.clearForcedDisplaySize(displayId); } return 0; } private int runDisplayDensity(PrintWriter pw) throws RemoteException { String densityStr = getNextArg(); int density; if (densityStr == null) { private void printInitialDisplayDensity(PrintWriter pw , int displayId) { try { int initialDensity = mInterface.getInitialDisplayDensity(Display.DEFAULT_DISPLAY); int baseDensity = mInterface.getBaseDisplayDensity(Display.DEFAULT_DISPLAY); final int initialDensity = mInterface.getInitialDisplayDensity(displayId); final int baseDensity = mInterface.getBaseDisplayDensity(displayId); pw.println("Physical density: " + initialDensity); if (initialDensity != baseDensity) { pw.println("Override density: " + baseDensity); } } catch (RemoteException e) { // Can't call getInitialDisplayDensity() on IWindowManager or // Can't call getBaseDisplayDensity() on IWindowManager pw.println("Remote exception: " + e); } } private int runDisplayDensity(PrintWriter pw) throws RemoteException { String densityStr = getNextArg(); int density; final int displayId = getDisplayId(densityStr); if (densityStr == null) { printInitialDisplayDensity(pw, displayId); return 0; } else if ("-d".equals(densityStr)) { printInitialDisplayDensity(pw, displayId); return 0; } else if ("reset".equals(densityStr)) { density = -1; Loading @@ -161,11 +194,10 @@ public class WindowManagerShellCommand extends ShellCommand { } if (density > 0) { // TODO(multidisplay): For now Configuration only applies to main screen. mInterface.setForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, density, mInterface.setForcedDisplayDensityForUser(displayId, density, UserHandle.USER_CURRENT); } else { mInterface.clearForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, mInterface.clearForcedDisplayDensityForUser(displayId, UserHandle.USER_CURRENT); } return 0; Loading @@ -174,6 +206,7 @@ public class WindowManagerShellCommand extends ShellCommand { private int runDisplayOverscan(PrintWriter pw) throws RemoteException { String overscanStr = getNextArgRequired(); Rect rect = new Rect(); final int displayId = getDisplayId(overscanStr); if ("reset".equals(overscanStr)) { rect.set(0, 0, 0, 0); } else { Loading @@ -190,17 +223,16 @@ public class WindowManagerShellCommand extends ShellCommand { rect.bottom = Integer.parseInt(matcher.group(4)); } mInterface.setOverscan(Display.DEFAULT_DISPLAY, rect.left, rect.top, rect.right, rect.bottom); mInterface.setOverscan(displayId, rect.left, rect.top, rect.right, rect.bottom); return 0; } private int runDisplayScaling(PrintWriter pw) throws RemoteException { String scalingStr = getNextArgRequired(); if ("auto".equals(scalingStr)) { mInterface.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 0); mInterface.setForcedDisplayScalingMode(getDisplayId(scalingStr), 0); } else if ("off".equals(scalingStr)) { mInterface.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 1); mInterface.setForcedDisplayScalingMode(getDisplayId(scalingStr), 1); } else { getErrPrintWriter().println("Error: scaling must be 'auto' or 'off'"); return -1; Loading @@ -213,14 +245,14 @@ public class WindowManagerShellCommand extends ShellCommand { return 0; } private int parseDimension(String s) throws NumberFormatException { private int parseDimension(String s, int displayId) throws NumberFormatException { if (s.endsWith("px")) { return Integer.parseInt(s.substring(0, s.length() - 2)); } if (s.endsWith("dp")) { int density; try { density = mInterface.getBaseDisplayDensity(Display.DEFAULT_DISPLAY); density = mInterface.getBaseDisplayDensity(displayId); } catch (RemoteException e) { density = DisplayMetrics.DENSITY_DEFAULT; } Loading @@ -236,14 +268,14 @@ public class WindowManagerShellCommand extends ShellCommand { pw.println("Window manager (window) commands:"); pw.println(" help"); pw.println(" Print this help text."); pw.println(" size [reset|WxH|WdpxHdp]"); pw.println(" size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]"); pw.println(" Return or override display size."); pw.println(" width and height in pixels unless suffixed with 'dp'."); pw.println(" density [reset|DENSITY]"); pw.println(" density [reset|DENSITY] [-d DISPLAY_ID]"); pw.println(" Return or override display density."); pw.println(" overscan [reset|LEFT,TOP,RIGHT,BOTTOM]"); pw.println(" overscan [reset|LEFT,TOP,RIGHT,BOTTOM] [-d DISPLAY ID]"); pw.println(" Set overscan area for display."); pw.println(" scaling [off|auto]"); pw.println(" scaling [off|auto] [-d DISPLAY_ID]"); pw.println(" Set display scaling mode."); pw.println(" dismiss-keyguard"); pw.println(" Dismiss the keyguard, prompting user for auth if necessary."); Loading Loading
services/core/java/com/android/server/wm/WindowManagerService.java +3 −15 Original line number Diff line number Diff line Loading @@ -5069,9 +5069,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5104,9 +5102,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5186,9 +5182,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final long ident = Binder.clearCallingIdentity(); try { synchronized(mWindowMap) { Loading Loading @@ -5235,9 +5229,6 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final int targetUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, true, "setForcedDisplayDensityForUser", Loading Loading @@ -5266,9 +5257,6 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Must hold permission " + android.Manifest.permission.WRITE_SECURE_SETTINGS); } if (displayId != DEFAULT_DISPLAY) { throw new IllegalArgumentException("Can only set the default display"); } final int callingUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, true, "clearForcedDisplayDensityForUser", Loading
services/core/java/com/android/server/wm/WindowManagerShellCommand.java +75 −43 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.os.Build.IS_USER; import android.graphics.Point; import android.graphics.Rect; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ShellCommand; import android.os.UserHandle; Loading @@ -28,10 +27,6 @@ import android.util.DisplayMetrics; import android.view.Display; import android.view.IWindowManager; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; Loading Loading @@ -87,21 +82,48 @@ public class WindowManagerShellCommand extends ShellCommand { return -1; } private int runDisplaySize(PrintWriter pw) throws RemoteException { String size = getNextArg(); int w, h; if (size == null) { Point initialSize = new Point(); Point baseSize = new Point(); private int getDisplayId(String opt) { int displayId = Display.DEFAULT_DISPLAY; String option = "-d".equals(opt) ? opt : getNextOption(); if (option != null && "-d".equals(option)) { try { mInterface.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize); mInterface.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize); displayId = Integer.parseInt(getNextArgRequired()); } catch (NumberFormatException e) { getErrPrintWriter().println("Error: bad number " + e); } catch (IllegalArgumentException e) { getErrPrintWriter().println("Error: " + e); } } return displayId; } private void printInitialDisplaySize(PrintWriter pw , int displayId) { final Point initialSize = new Point(); final Point baseSize = new Point(); try { mInterface.getInitialDisplaySize(displayId, initialSize); mInterface.getBaseDisplaySize(displayId, baseSize); pw.println("Physical size: " + initialSize.x + "x" + initialSize.y); if (!initialSize.equals(baseSize)) { pw.println("Override size: " + baseSize.x + "x" + baseSize.y); } } catch (RemoteException e) { // Can't call getInitialDisplaySize() on IWindowManager or // Can't call getBaseDisplaySize() on IWindowManager pw.println("Remote exception: " + e); } } private int runDisplaySize(PrintWriter pw) throws RemoteException { String size = getNextArg(); int w, h; final int displayId = getDisplayId(size); if (size == null) { printInitialDisplaySize(pw, displayId); return 0; } else if ("-d".equals(size)) { printInitialDisplaySize(pw, displayId); return 0; } else if ("reset".equals(size)) { w = h = -1; Loading @@ -114,8 +136,8 @@ public class WindowManagerShellCommand extends ShellCommand { String wstr = size.substring(0, div); String hstr = size.substring(div+1); try { w = parseDimension(wstr); h = parseDimension(hstr); w = parseDimension(wstr, displayId); h = parseDimension(hstr, displayId); } catch (NumberFormatException e) { getErrPrintWriter().println("Error: bad number " + e); return -1; Loading @@ -123,27 +145,38 @@ public class WindowManagerShellCommand extends ShellCommand { } if (w >= 0 && h >= 0) { // TODO(multidisplay): For now Configuration only applies to main screen. mInterface.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h); mInterface.setForcedDisplaySize(displayId, w, h); } else { mInterface.clearForcedDisplaySize(Display.DEFAULT_DISPLAY); mInterface.clearForcedDisplaySize(displayId); } return 0; } private int runDisplayDensity(PrintWriter pw) throws RemoteException { String densityStr = getNextArg(); int density; if (densityStr == null) { private void printInitialDisplayDensity(PrintWriter pw , int displayId) { try { int initialDensity = mInterface.getInitialDisplayDensity(Display.DEFAULT_DISPLAY); int baseDensity = mInterface.getBaseDisplayDensity(Display.DEFAULT_DISPLAY); final int initialDensity = mInterface.getInitialDisplayDensity(displayId); final int baseDensity = mInterface.getBaseDisplayDensity(displayId); pw.println("Physical density: " + initialDensity); if (initialDensity != baseDensity) { pw.println("Override density: " + baseDensity); } } catch (RemoteException e) { // Can't call getInitialDisplayDensity() on IWindowManager or // Can't call getBaseDisplayDensity() on IWindowManager pw.println("Remote exception: " + e); } } private int runDisplayDensity(PrintWriter pw) throws RemoteException { String densityStr = getNextArg(); int density; final int displayId = getDisplayId(densityStr); if (densityStr == null) { printInitialDisplayDensity(pw, displayId); return 0; } else if ("-d".equals(densityStr)) { printInitialDisplayDensity(pw, displayId); return 0; } else if ("reset".equals(densityStr)) { density = -1; Loading @@ -161,11 +194,10 @@ public class WindowManagerShellCommand extends ShellCommand { } if (density > 0) { // TODO(multidisplay): For now Configuration only applies to main screen. mInterface.setForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, density, mInterface.setForcedDisplayDensityForUser(displayId, density, UserHandle.USER_CURRENT); } else { mInterface.clearForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, mInterface.clearForcedDisplayDensityForUser(displayId, UserHandle.USER_CURRENT); } return 0; Loading @@ -174,6 +206,7 @@ public class WindowManagerShellCommand extends ShellCommand { private int runDisplayOverscan(PrintWriter pw) throws RemoteException { String overscanStr = getNextArgRequired(); Rect rect = new Rect(); final int displayId = getDisplayId(overscanStr); if ("reset".equals(overscanStr)) { rect.set(0, 0, 0, 0); } else { Loading @@ -190,17 +223,16 @@ public class WindowManagerShellCommand extends ShellCommand { rect.bottom = Integer.parseInt(matcher.group(4)); } mInterface.setOverscan(Display.DEFAULT_DISPLAY, rect.left, rect.top, rect.right, rect.bottom); mInterface.setOverscan(displayId, rect.left, rect.top, rect.right, rect.bottom); return 0; } private int runDisplayScaling(PrintWriter pw) throws RemoteException { String scalingStr = getNextArgRequired(); if ("auto".equals(scalingStr)) { mInterface.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 0); mInterface.setForcedDisplayScalingMode(getDisplayId(scalingStr), 0); } else if ("off".equals(scalingStr)) { mInterface.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 1); mInterface.setForcedDisplayScalingMode(getDisplayId(scalingStr), 1); } else { getErrPrintWriter().println("Error: scaling must be 'auto' or 'off'"); return -1; Loading @@ -213,14 +245,14 @@ public class WindowManagerShellCommand extends ShellCommand { return 0; } private int parseDimension(String s) throws NumberFormatException { private int parseDimension(String s, int displayId) throws NumberFormatException { if (s.endsWith("px")) { return Integer.parseInt(s.substring(0, s.length() - 2)); } if (s.endsWith("dp")) { int density; try { density = mInterface.getBaseDisplayDensity(Display.DEFAULT_DISPLAY); density = mInterface.getBaseDisplayDensity(displayId); } catch (RemoteException e) { density = DisplayMetrics.DENSITY_DEFAULT; } Loading @@ -236,14 +268,14 @@ public class WindowManagerShellCommand extends ShellCommand { pw.println("Window manager (window) commands:"); pw.println(" help"); pw.println(" Print this help text."); pw.println(" size [reset|WxH|WdpxHdp]"); pw.println(" size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]"); pw.println(" Return or override display size."); pw.println(" width and height in pixels unless suffixed with 'dp'."); pw.println(" density [reset|DENSITY]"); pw.println(" density [reset|DENSITY] [-d DISPLAY_ID]"); pw.println(" Return or override display density."); pw.println(" overscan [reset|LEFT,TOP,RIGHT,BOTTOM]"); pw.println(" overscan [reset|LEFT,TOP,RIGHT,BOTTOM] [-d DISPLAY ID]"); pw.println(" Set overscan area for display."); pw.println(" scaling [off|auto]"); pw.println(" scaling [off|auto] [-d DISPLAY_ID]"); pw.println(" Set display scaling mode."); pw.println(" dismiss-keyguard"); pw.println(" Dismiss the keyguard, prompting user for auth if necessary."); Loading