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

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

Merge "Expose setFixedToUserRotation via IWindowManager."

parents 7e9d566e a3f19030
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -65,6 +65,22 @@ import android.view.SurfaceControl;
 */
interface IWindowManager
{
    /**
     * No overridden behavior is provided in terms of fixing rotation to user rotation. Use
     * other flags to derive the default behavior, such as {@link WindowManagerService#mIsPc}
     * and {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}.
     */
    const int FIXED_TO_USER_ROTATION_DEFAULT = 0;
    /**
     * Don't fix display rotation to {@link DisplayRotation#mUserRotation} only. Always allow
     * other factors to play a role in deciding display rotation.
     */
    const int FIXED_TO_USER_ROTATION_DISABLED = 1;
    /**
     * Only use {@link DisplayRotation#mUserRotation} as the display rotation.
     */
    const int FIXED_TO_USER_ROTATION_ENABLED = 2;

    /**
     * ===== NOTICE =====
     * The first three methods must remain the first three methods. Scripts
@@ -272,6 +288,11 @@ interface IWindowManager
     */
    boolean isDisplayRotationFrozen(int displayId);

    /**
    *  Sets if display rotation is fixed to user specified value for given displayId.
    */
    void setFixedToUserRotation(int displayId, int fixedToUserRotation);

    /**
     * Screenshot the current wallpaper layer, including the whole screen.
     */
+6 −27
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.provider.Settings;
import android.util.Slog;
import android.util.SparseArray;
import android.view.IDisplayWindowRotationCallback;
import android.view.IWindowManager;
import android.view.Surface;
import android.view.WindowContainerTransaction;

@@ -183,33 +184,12 @@ public class DisplayRotation {
     */
    private boolean mDefaultFixedToUserRotation;

    /**
     * No overridden behavior is provided in terms of fixing rotation to user rotation. Use other
     * flags to derive the default behavior, such as {@link WindowManagerService#mIsPc} and
     * {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}.
     */
    static final int FIXED_TO_USER_ROTATION_DEFAULT = 0;
    /**
     * Don't fix display rotation to {@link #mUserRotation} only. Always allow other factors to play
     * a role in deciding display rotation.
     */
    static final int FIXED_TO_USER_ROTATION_DISABLED = 1;
    /**
     * Only use {@link #mUserRotation} as the display rotation.
     */
    static final int FIXED_TO_USER_ROTATION_ENABLED = 2;
    @IntDef({ FIXED_TO_USER_ROTATION_DEFAULT, FIXED_TO_USER_ROTATION_DISABLED,
            FIXED_TO_USER_ROTATION_ENABLED })
    @Retention(RetentionPolicy.SOURCE)
    @interface FixedToUserRotation {}

    /**
     * A flag to indicate if the display rotation should be fixed to user specified rotation
     * regardless of all other states (including app requrested orientation). {@code true} the
     * display rotation should be fixed to user specified rotation, {@code false} otherwise.
     */
    @FixedToUserRotation
    private int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT;
    private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;

    private int mDemoHdmiRotation;
    private int mDemoRotation;
@@ -723,8 +703,7 @@ public class DisplayRotation {
        }
    }

    void restoreSettings(int userRotationMode, int userRotation,
            @FixedToUserRotation int fixedToUserRotation) {
    void restoreSettings(int userRotationMode, int userRotation, int fixedToUserRotation) {
        mFixedToUserRotation = fixedToUserRotation;

        // We will retrieve user rotation and user rotation mode from settings for default display.
@@ -746,7 +725,7 @@ public class DisplayRotation {
        mUserRotation = userRotation;
    }

    void setFixedToUserRotation(@FixedToUserRotation int fixedToUserRotation) {
    void setFixedToUserRotation(int fixedToUserRotation) {
        if (mFixedToUserRotation == fixedToUserRotation) {
            return;
        }
@@ -808,9 +787,9 @@ public class DisplayRotation {

    boolean isFixedToUserRotation() {
        switch (mFixedToUserRotation) {
            case FIXED_TO_USER_ROTATION_DISABLED:
            case IWindowManager.FIXED_TO_USER_ROTATION_DISABLED:
                return false;
            case FIXED_TO_USER_ROTATION_ENABLED:
            case IWindowManager.FIXED_TO_USER_ROTATION_ENABLED:
                return true;
            default:
                return mDefaultFixedToUserRotation;
+5 −7
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;

import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_AUTO;
import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_DISABLED;
import static com.android.server.wm.DisplayRotation.FIXED_TO_USER_ROTATION_DEFAULT;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

@@ -38,6 +37,7 @@ import android.util.Xml;
import android.view.Display;
import android.view.DisplayAddress;
import android.view.DisplayInfo;
import android.view.IWindowManager;
import android.view.Surface;

import com.android.internal.annotations.VisibleForTesting;
@@ -111,8 +111,7 @@ class DisplayWindowSettings {
        private boolean mShouldShowWithInsecureKeyguard = false;
        private boolean mShouldShowSystemDecors = false;
        private boolean mShouldShowIme = false;
        private @DisplayRotation.FixedToUserRotation int mFixedToUserRotation =
                FIXED_TO_USER_ROTATION_DEFAULT;
        private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;

        private Entry(String name) {
            mName = name;
@@ -145,7 +144,7 @@ class DisplayWindowSettings {
                    && !mShouldShowWithInsecureKeyguard
                    && !mShouldShowSystemDecors
                    && !mShouldShowIme
                    && mFixedToUserRotation == FIXED_TO_USER_ROTATION_DEFAULT;
                    && mFixedToUserRotation == IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;
        }
    }

@@ -242,8 +241,7 @@ class DisplayWindowSettings {
        writeSettingsIfNeeded(entry, displayInfo);
    }

    void setFixedToUserRotation(DisplayContent displayContent,
            @DisplayRotation.FixedToUserRotation int fixedToUserRotation) {
    void setFixedToUserRotation(DisplayContent displayContent, int fixedToUserRotation) {
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        final Entry entry = getOrCreateEntry(displayInfo);
        entry.mFixedToUserRotation = fixedToUserRotation;
@@ -610,7 +608,7 @@ class DisplayWindowSettings {
                if (entry.mShouldShowIme) {
                    out.attribute(null, "shouldShowIme", Boolean.toString(entry.mShouldShowIme));
                }
                if (entry.mFixedToUserRotation != FIXED_TO_USER_ROTATION_DEFAULT) {
                if (entry.mFixedToUserRotation != IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT) {
                    out.attribute(null, "fixedToUserRotation",
                            Integer.toString(entry.mFixedToUserRotation));
                }
+6 −2
Original line number Diff line number Diff line
@@ -3545,8 +3545,12 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void setRotateForApp(int displayId,
            @DisplayRotation.FixedToUserRotation int fixedToUserRotation) {
    @Override
    public void setFixedToUserRotation(int displayId, int fixedToUserRotation) {
        if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION,
                "freezeRotation()")) {
            throw new SecurityException("Requires SET_ORIENTATION permission");
        }
        synchronized (mGlobalLock) {
            final DisplayContent display = mRoot.getDisplayContent(displayId);
            if (display == null) {
+6 −6
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ public class WindowManagerShellCommand extends ShellCommand {
        }
    }

    private int runSetFixToUserRotation(PrintWriter pw) {
    private int runSetFixToUserRotation(PrintWriter pw) throws RemoteException {
        int displayId = Display.DEFAULT_DISPLAY;
        String arg = getNextArgRequired();
        if ("-d".equals(arg)) {
@@ -329,16 +329,16 @@ public class WindowManagerShellCommand extends ShellCommand {
            arg = getNextArgRequired();
        }

        final @DisplayRotation.FixedToUserRotation  int fixedToUserRotation;
        final int fixedToUserRotation;
        switch (arg) {
            case "enabled":
                fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_ENABLED;
                fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_ENABLED;
                break;
            case "disabled":
                fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED;
                fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DISABLED;
                break;
            case "default":
                fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED;
                fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;
                break;
            default:
                getErrPrintWriter().println("Error: expecting enabled, disabled or default, but we "
@@ -346,7 +346,7 @@ public class WindowManagerShellCommand extends ShellCommand {
                return -1;
        }

        mInternal.setRotateForApp(displayId, fixedToUserRotation);
        mInterface.setFixedToUserRotation(displayId, fixedToUserRotation);
        return 0;
    }

Loading