Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 707e6aae authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Add shell command to reset ignore-orientation-request" into main

parents c16946dc 05775425
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ class DisplayWindowSettings {
    }

    void setIgnoreOrientationRequest(@NonNull DisplayContent displayContent,
            boolean ignoreOrientationRequest) {
            @Nullable Boolean ignoreOrientationRequest) {
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        final SettingsProvider.SettingsEntry overrideSettings =
                mSettingsProvider.getOverrideSettings(displayInfo);
+17 −0
Original line number Diff line number Diff line
@@ -4342,6 +4342,23 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Nullable
    Boolean resetIgnoreOrientationRequest(int displayId) {
        synchronized (mGlobalLock) {
            final DisplayContent display = mRoot.getDisplayContent(displayId);
            if (display == null) {
                return null;
            }
            display.mHasSetIgnoreOrientationRequest = false;
            // Clear existing override settings.
            mDisplayWindowSettings.setIgnoreOrientationRequest(display,
                    null /* ignoreOrientationRequest */);
            // Reload from settings in case there is built-in config.
            mDisplayWindowSettings.applyRotationSettingsToDisplayLocked(display);
            return display.getIgnoreOrientationRequest();
        }
    }

    /**
     * Controls whether ignore orientation request logic in {@link DisplayArea} is disabled
     * at runtime and how to optionally map some requested orientations to others.
+15 −3
Original line number Diff line number Diff line
@@ -578,6 +578,18 @@ public class WindowManagerShellCommand extends ShellCommand {
            displayId = Integer.parseInt(getNextArgRequired());
            arg = getNextArgRequired();
        }
        if ("reset".equals(arg)) {
            final Boolean result = mInternal.resetIgnoreOrientationRequest(displayId);
            if (result != null) {
                pw.println("Reset ignoreOrientationRequest to " + result + " for displayId="
                        + displayId);
                return 0;
            } else {
                getErrPrintWriter().println(
                        "Unable to reset ignoreOrientationRequest for displayId=" + displayId);
                return -1;
            }
        }

        final boolean ignoreOrientationRequest;
        switch (arg) {
@@ -590,7 +602,7 @@ public class WindowManagerShellCommand extends ShellCommand {
                ignoreOrientationRequest = false;
                break;
            default:
                getErrPrintWriter().println("Error: expecting true, 1, false, 0, but we "
                getErrPrintWriter().println("Error: expecting true, 1, false, 0, reset, but we "
                        + "get " + arg);
                return -1;
        }
@@ -1525,7 +1537,7 @@ public class WindowManagerShellCommand extends ShellCommand {
        mInterface.setFixedToUserRotation(displayId, IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT);

        // set-ignore-orientation-request
        mInterface.setIgnoreOrientationRequest(displayId, false /* ignoreOrientationRequest */);
        mInternal.resetIgnoreOrientationRequest(displayId);

        // set-letterbox-style
        resetLetterboxStyle();
@@ -1568,7 +1580,7 @@ public class WindowManagerShellCommand extends ShellCommand {
        pw.println("  fixed-to-user-rotation [-d DISPLAY_ID] [enabled|disabled|default");
        pw.println("      |enabled_if_no_auto_rotation]");
        pw.println("    Print or set rotating display for app requested orientation.");
        pw.println("  set-ignore-orientation-request [-d DISPLAY_ID] [true|1|false|0]");
        pw.println("  set-ignore-orientation-request [-d DISPLAY_ID] [reset|true|1|false|0]");
        pw.println("  get-ignore-orientation-request [-d DISPLAY_ID] ");
        pw.println("    If app requested orientation should be ignored.");
        pw.println("  set-sandbox-display-apis [true|1|false|0]");