Add reset wm shell command to reset all

Command to reset all override settings to default.

Test: adb shell wm reset
Change-Id: Ie34db63a1cc3bf9ce4c05ea5ee6f151aeb6dcb94
This commit is contained in:
Chris Li
2020-10-21 18:24:31 -07:00
parent 42e40336cc
commit 2c327f2f3d

View File

@@ -111,6 +111,8 @@ public class WindowManagerShellCommand extends ShellCommand {
return runGetIgnoreOrientationRequest(pw);
case "dump-visible-window-views":
return runDumpVisibleWindowViews(pw);
case "reset":
return runReset(pw);
default:
return handleDefaultCommands(cmd);
}
@@ -507,6 +509,34 @@ public class WindowManagerShellCommand extends ShellCommand {
return 0;
}
private int runReset(PrintWriter pw) throws RemoteException {
int displayId = getDisplayId(getNextArg());
// size
mInterface.clearForcedDisplaySize(displayId);
// density
mInterface.clearForcedDisplayDensityForUser(displayId, UserHandle.USER_CURRENT);
// folded-area
mInternal.setOverrideFoldedArea(new Rect());
// scaling
mInterface.setForcedDisplayScalingMode(displayId, DisplayContent.FORCE_SCALING_MODE_AUTO);
// user-rotation
mInternal.thawDisplayRotation(displayId);
// fixed-to-user-rotation
mInterface.setFixedToUserRotation(displayId, IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT);
// set-ignore-orientation-request
mInterface.setIgnoreOrientationRequest(displayId, false /* ignoreOrientationRequest */);
pw.println("Reset all settings for displayId=" + displayId);
return 0;
}
@Override
public void onHelp() {
PrintWriter pw = getOutPrintWriter();
@@ -533,6 +563,8 @@ public class WindowManagerShellCommand extends ShellCommand {
pw.println(" set-ignore-orientation-request [-d DISPLAY_ID] [true|1|false|0]");
pw.println(" get-ignore-orientation-request [-d DISPLAY_ID] ");
pw.println(" If app requested orientation should be ignored.");
pw.println(" reset [-d DISPLAY_ID]");
pw.println(" Reset all override settings.");
if (!IS_USER) {
pw.println(" tracing (start | stop)");
pw.println(" Start or stop window tracing.");