android: wm: add support for display rotation
Signed-off-by: hmz007 <hmz007@gmail.com>
This commit is contained in:
+40
@@ -97,6 +97,8 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
return runDisplayDensity(pw);
|
||||
case "folded-area":
|
||||
return runDisplayFoldedArea(pw);
|
||||
case "rotation":
|
||||
return runDisplayRotation(pw);
|
||||
case "scaling":
|
||||
return runDisplayScaling(pw);
|
||||
case "dismiss-keyguard":
|
||||
@@ -352,6 +354,42 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int runDisplayRotation(PrintWriter pw) throws RemoteException {
|
||||
String rotationStr = getNextArg();
|
||||
int rotation;
|
||||
if (rotationStr == null) {
|
||||
rotation = mInterface.getDefaultDisplayRotation();
|
||||
pw.println("Current rotation: " + rotation);
|
||||
return 0;
|
||||
} else if ("help".equals(rotationStr)) {
|
||||
pw.println("usage: wm rotation [0|90|180|270]\n");
|
||||
return 0;
|
||||
} else {
|
||||
try {
|
||||
rotation = Integer.parseInt(rotationStr);
|
||||
} catch (NumberFormatException e) {
|
||||
getErrPrintWriter().println("Error: bad number " + e);
|
||||
return -1;
|
||||
}
|
||||
if ((rotation % 90) != 0) {
|
||||
getErrPrintWriter().println("Error: rotation must be [0|90|180|270]");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// 0 - ROTATION_0
|
||||
// 1 - ROTATION_90
|
||||
// 2 - ROTATION_180
|
||||
// 3 - ROTATION_270
|
||||
rotation /= 90;
|
||||
mInterface.freezeRotation(rotation);
|
||||
} catch (RemoteException e) {
|
||||
getErrPrintWriter().println("Error: Can't set display rotation " + e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int runDisplayScaling(PrintWriter pw) throws RemoteException {
|
||||
String scalingStr = getNextArgRequired();
|
||||
if ("auto".equals(scalingStr)) {
|
||||
@@ -1467,6 +1505,8 @@ public class WindowManagerShellCommand extends ShellCommand {
|
||||
pw.println(" Return or override display density.");
|
||||
pw.println(" folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]");
|
||||
pw.println(" Return or override folded area.");
|
||||
pw.println(" rotation [0|90|180|270]");
|
||||
pw.println(" Set display rotation.");
|
||||
pw.println(" scaling [off|auto] [-d DISPLAY_ID]");
|
||||
pw.println(" Set display scaling mode.");
|
||||
pw.println(" dismiss-keyguard");
|
||||
|
||||
Reference in New Issue
Block a user