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

Commit 17c77995 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support ignoring app orientation request per display"

parents cbf137e2 db900f8a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -342,6 +342,11 @@ interface IWindowManager
    */
    void setFixedToUserRotation(int displayId, int fixedToUserRotation);

   /**
    *  Sets if all requested fixed orientation should be ignored for given displayId.
    */
    void setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest);

    /**
     * Screenshot the current wallpaper layer, including the whole screen.
     */
+12 −0
Original line number Diff line number Diff line
@@ -101,6 +101,18 @@ public class WindowManagerWrapper {
        params.providesInsetsTypes = providesInsetsTypes;
    }

    /**
     *  Sets if app requested fixed orientation should be ignored for given displayId.
     */
    public void setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest) {
        try {
            WindowManagerGlobal.getWindowManagerService().setIgnoreOrientationRequest(
                    displayId, ignoreOrientationRequest);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to setIgnoreOrientationRequest()", e);
        }
    }

    /**
     * @return the stable insets for the primary display.
     */
+4 −0
Original line number Diff line number Diff line
@@ -181,6 +181,10 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
        return false;
    }

    boolean getIgnoreOrientationRequest() {
        return mIgnoreOrientationRequest;
    }

    /**
     * When a {@link DisplayArea} is repositioned, it should only be moved among its siblings of the
     * same {@link Type}.
+7 −2
Original line number Diff line number Diff line
@@ -5356,8 +5356,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return mDisplayPolicy.getSystemUiContext();
    }

    Point getDisplayPosition() {
        return mWmService.mDisplayManagerInternal.getDisplayPosition(getDisplayId());
    @Override
    boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
        if (mIgnoreOrientationRequest == ignoreOrientationRequest) return false;
        final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest);
        mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest(
                this, mIgnoreOrientationRequest);
        return rotationChanged;
    }

    /**
+20 −1
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ class DisplayWindowSettings {
        private boolean mShouldShowSystemDecors = false;
        private boolean mShouldShowIme = false;
        private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;
        private boolean mIgnoreOrientationRequest = false;

        private Entry(String name) {
            mName = name;
@@ -131,6 +132,7 @@ class DisplayWindowSettings {
            mShouldShowSystemDecors = copyFrom.mShouldShowSystemDecors;
            mShouldShowIme = copyFrom.mShouldShowIme;
            mFixedToUserRotation = copyFrom.mFixedToUserRotation;
            mIgnoreOrientationRequest = copyFrom.mIgnoreOrientationRequest;
        }

        /** @return {@code true} if all values are default. */
@@ -144,7 +146,8 @@ class DisplayWindowSettings {
                    && !mShouldShowWithInsecureKeyguard
                    && !mShouldShowSystemDecors
                    && !mShouldShowIme
                    && mFixedToUserRotation == IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;
                    && mFixedToUserRotation == IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT
                    && !mIgnoreOrientationRequest;
        }
    }

@@ -248,6 +251,15 @@ class DisplayWindowSettings {
        writeSettingsIfNeeded(entry, displayInfo);
    }

    void setIgnoreOrientationRequest(
            DisplayContent displayContent, boolean ignoreOrientationRequest) {
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        final Entry entry = getOrCreateEntry(displayInfo);
        if (entry.mIgnoreOrientationRequest == ignoreOrientationRequest) return;
        entry.mIgnoreOrientationRequest = ignoreOrientationRequest;
        writeSettingsIfNeeded(entry, displayInfo);
    }

    private int getWindowingModeLocked(Entry entry, DisplayContent dc) {
        int windowingMode = entry != null ? entry.mWindowingMode
                : WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -389,6 +401,7 @@ class DisplayWindowSettings {
        final boolean hasSizeOverride = entry.mForcedWidth != 0 && entry.mForcedHeight != 0;
        dc.mIsDensityForced = hasDensityOverride;
        dc.mIsSizeForced = hasSizeOverride;
        dc.setIgnoreOrientationRequest(entry.mIgnoreOrientationRequest);

        final int width = hasSizeOverride ? entry.mForcedWidth : dc.mBaseDisplayWidth;
        final int height = hasSizeOverride ? entry.mForcedHeight : dc.mBaseDisplayHeight;
@@ -529,6 +542,8 @@ class DisplayWindowSettings {
            entry.mShouldShowSystemDecors = getBooleanAttribute(parser, "shouldShowSystemDecors");
            entry.mShouldShowIme = getBooleanAttribute(parser, "shouldShowIme");
            entry.mFixedToUserRotation = getIntAttribute(parser, "fixedToUserRotation");
            entry.mIgnoreOrientationRequest
                    = getBooleanAttribute(parser, "ignoreOrientationRequest");
            mEntries.put(name, entry);
        }
        XmlUtils.skipCurrentTag(parser);
@@ -613,6 +628,10 @@ class DisplayWindowSettings {
                    out.attribute(null, "fixedToUserRotation",
                            Integer.toString(entry.mFixedToUserRotation));
                }
                if (entry.mIgnoreOrientationRequest) {
                    out.attribute(null, "ignoreOrientationRequest",
                            Boolean.toString(entry.mIgnoreOrientationRequest));
                }
                out.endTag(null, "display");
            }

Loading