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

Commit 05775425 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add shell command to reset ignore-orientation-request

In case some tests don't restore do default value after overriding
the flag. This provides the ability for the tests that want to
verify the default behavior.

Bug: 391792293
Flag: EXEMPT TEST_ONLY
Test: On a large screen device:
       adb shell cmd window set-ignore-orientation-request false
       adb shell cmd window set-ignore-orientation-request reset
      The output will be:
       Reset ignoreOrientationRequest to true for displayId=0
Change-Id: I35dc4e1c6a7cc23e95ddfade5a7ca17b1bdb0ebb
parent 71378c18
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,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
@@ -4319,6 +4319,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
@@ -577,6 +577,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) {
@@ -589,7 +601,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;
        }
@@ -1558,7 +1570,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();
@@ -1601,7 +1613,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]");