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

Commit 11ece527 authored by Shivangi Dubey's avatar Shivangi Dubey Committed by Android (Google) Code Review
Browse files

Merge "Create an IPC for requesting change to device state auto rotate setting" into main

parents c6847900 bf952b7f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -362,6 +362,12 @@ interface IWindowManager
     */
    int getPreferredOptionsPanelGravity(int displayId);

    /**
     * Requests to update value of setting key {@link Settings.Secure#DEVICE_STATE_ROTATION_LOCK} to
     * {@link autoRotate} for {@link deviceState}.
     */
    oneway void setDeviceStateAutoRotateSetting(int deviceState, boolean autoRotate);

    /**
     * Equivalent to calling {@link #freezeDisplayRotation(int, int)} with {@link
     * android.view.Display#DEFAULT_DISPLAY} and given rotation.
+14 −0
Original line number Diff line number Diff line
@@ -94,6 +94,20 @@ public final class RotationPolicy {
                        UserHandle.USER_CURRENT) == 0;
    }

    /**
     * Requests to update value of setting key {@link Settings.Secure.DEVICE_STATE_ROTATION_LOCK} to
     * {@link autoRotate} for {@link deviceState}.
     */
    public static void requestDeviceStateAutoRotateSettingChange(int deviceState,
            boolean autoRotate) {
        try {
            IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
            wm.setDeviceStateAutoRotateSetting(deviceState, autoRotate);
        } catch (RemoteException exc) {
            Log.w(TAG, "Unable to save device state auto-rotate setting: " + exc.getMessage());
        }
    }

    /**
     * Returns true if rotation lock is enabled.
     */
+4 −0
Original line number Diff line number Diff line
@@ -792,6 +792,10 @@ public class DisplayRotation {
        }
    }

    void requestDeviceStateAutoRotateSettingChange(int deviceState, boolean autoRotate) {
        // TODO(b/350946537) Redirect request to DeviceStateAutoRotateSettingController
    }

    void freezeRotation(int rotation, String caller) {
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) {
            rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation);
+17 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ import static com.android.server.wm.WindowManagerServiceDumpProto.INPUT_METHOD_W
import static com.android.server.wm.WindowManagerServiceDumpProto.POLICY;
import static com.android.server.wm.WindowManagerServiceDumpProto.ROOT_WINDOW_CONTAINER;
import static com.android.server.wm.WindowManagerServiceDumpProto.WINDOW_FRAMES_VALID;
import static com.android.window.flags.Flags.enableDeviceStateAutoRotateSettingRefactor;
import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static com.android.window.flags.Flags.enablePresentationForConnectedDisplays;
import static com.android.window.flags.Flags.multiCrop;
@@ -4487,6 +4488,22 @@ public class WindowManagerService extends IWindowManager.Stub
                || !mAppCompatConfiguration.isIgnoreOrientationRequestAllowed();
    }

    @Override
    public void setDeviceStateAutoRotateSetting(int deviceState, boolean autoRotate) {
        if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION,
                "setDeviceStateAutoRotateSetting()")) {
            throw new SecurityException("Requires SET_ORIENTATION permission");
        }
        if (!enableDeviceStateAutoRotateSettingRefactor()) {
            return;
        }
        synchronized (mGlobalLock) {
            final DisplayContent display = mRoot.getDefaultDisplay();
            display.getDisplayRotation().requestDeviceStateAutoRotateSettingChange(deviceState,
                    autoRotate);
        }
    }

    @Override
    public void freezeRotation(int rotation, String caller) {
        freezeDisplayRotation(Display.DEFAULT_DISPLAY, rotation, caller);