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

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

Merge "Support rotation on secondary displays (1/N)"

parents 2c80770f 654a6f90
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.IntArray;
import android.util.SparseArray;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceControl;

/**
@@ -61,6 +62,15 @@ public abstract class DisplayManagerInternal {
     */
    public abstract boolean isProximitySensorAvailable();

    /**
     * Take a screenshot of the specified display into the provided {@link Surface}.
     *
     * @param displayId The display id to take the screenshot of.
     * @param outSurface The {@link Surface} to take the screenshot into.
     * @return True if the screenshot is taken.
     */
    public abstract boolean screenshot(int displayId, Surface outSurface);

    /**
     * Returns information about the specified logical display.
     *
+5 −1
Original line number Diff line number Diff line
@@ -77,7 +77,11 @@ public final class RotationPolicy {
            final Point size = new Point();
            final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
            try {
                wm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, size);
                final Display display = context.getDisplay();
                final int displayId = display != null
                        ? display.getDisplayId()
                        : Display.DEFAULT_DISPLAY;
                wm.getInitialDisplaySize(displayId, size);
                return size.x < size.y ?
                        Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
            } catch (RemoteException e) {
+18 −0
Original line number Diff line number Diff line
@@ -2164,6 +2164,24 @@ public final class DisplayManagerService extends SystemService {
            }
        }

        @Override
        public boolean screenshot(int displayId, Surface outSurface) {
            synchronized (mSyncRoot) {
                final LogicalDisplay display = mLogicalDisplays.get(displayId);
                if (display != null) {
                    final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
                    if (device != null) {
                        final IBinder token = device.getDisplayTokenLocked();
                        if (token != null) {
                            SurfaceControl.screenshot(token, outSurface);
                            return true;
                        }
                    }
                }
            }
            return false;
        }

        @Override
        public DisplayInfo getDisplayInfo(int displayId) {
            return getDisplayInfoInternal(displayId, Process.myUid());
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class BlackFrame {
                    .setParent(null) // TODO: Work-around for b/69259549
                    .build();

            transaction.setLayerStack(surface, dc.getDisplayId());
            transaction.setAlpha(surface, 1);
            transaction.setLayer(surface, layer);
            transaction.show(surface);
+39 −8
Original line number Diff line number Diff line
@@ -303,6 +303,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    // Accessed directly by all users.
    private boolean mLayoutNeeded;
    int pendingLayoutChanges;
    int mDeferredRotationPauseCount;
    // TODO(multi-display): remove some of the usages.
    boolean isDefaultDisplay;
    /**
@@ -941,6 +942,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        return mLastWindowForcedOrientation;
    }

    /**
     * Temporarily pauses rotation changes until resumed.
     *
     * This can be used to prevent rotation changes from occurring while the user is
     * performing certain operations, such as drag and drop.
     *
     * This call nests and must be matched by an equal number of calls to
     * {@link #resumeRotationLocked}.
     */
    void pauseRotationLocked() {
        mDeferredRotationPauseCount++;
    }

    /**
     * Resumes normal rotation changes after being paused.
     */
    void resumeRotationLocked() {
        if (mDeferredRotationPauseCount <= 0) {
            return;
        }

        mDeferredRotationPauseCount--;
        if (mDeferredRotationPauseCount == 0) {
            final boolean changed = updateRotationUnchecked();
            if (changed) {
                mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, mDisplayId).sendToTarget();
            }
        }
    }

    /**
     * Update rotation of the display.
     *
@@ -964,7 +995,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    boolean updateRotationUnchecked(boolean forceUpdate) {
        ScreenRotationAnimation screenRotationAnimation;
        if (!forceUpdate) {
            if (mService.mDeferredRotationPauseCount > 0) {
            if (mDeferredRotationPauseCount > 0) {
                // Rotation updates have been paused temporarily.  Defer the update until
                // updates have been resumed.
                if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, rotation is paused.");
@@ -1065,9 +1096,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }

        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_ACTIVE;
        mService.mH.removeMessages(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT);
        mService.mH.sendEmptyMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT,
                WINDOW_FREEZE_TIMEOUT_DURATION);
        mService.mH.sendNewMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT,
                this, WINDOW_FREEZE_TIMEOUT_DURATION);

        setLayoutNeeded();
        final int[] anim = new int[2];
@@ -1124,9 +1154,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }, true /* traverseTopToBottom */);

        if (rotateSeamlessly) {
            mService.mH.removeMessages(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT);
            mService.mH.sendEmptyMessageDelayed(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT,
                    SEAMLESS_ROTATION_TIMEOUT_DURATION);
            mService.mH.sendNewMessageDelayed(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT,
                    this, SEAMLESS_ROTATION_TIMEOUT_DURATION);
        }

        for (int i = mService.mRotationWatchers.size() - 1; i >= 0; i--) {
@@ -2282,6 +2311,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        pw.println();
        pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq);
        pw.print(prefix);
        pw.print("mDeferredRotationPauseCount="); pw.println(mDeferredRotationPauseCount);

        pw.println();
        pw.println(prefix + "Application tokens in top down Z order:");
@@ -2876,7 +2907,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                mWallpaperController.adjustWallpaperWindows(this);
            }

            if (isDefaultDisplay && (pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) {
            if ((pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) {
                if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
                if (mService.updateOrientationFromAppTokensLocked(mDisplayId)) {
                    setLayoutNeeded();
Loading