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

Commit afb5399f authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Add Display Category Rear"

parents 3957b157 fc15d209
Loading
Loading
Loading
Loading
+37 −11
Original line number Diff line number Diff line
@@ -114,6 +114,23 @@ public final class DisplayManager {
    public static final String DISPLAY_CATEGORY_PRESENTATION =
            "android.hardware.display.category.PRESENTATION";

    /**
     * Display category: Rear displays.
     * <p>
     * This category can be used to identify complementary internal displays that are facing away
     * from the user.
     * Certain applications may present to this display.
     * Similar to presentation displays.
     * </p>
     *
     * @see android.app.Presentation
     * @see Display#FLAG_PRESENTATION
     * @see #getDisplays(String)
     * @hide
     */
    public static final String DISPLAY_CATEGORY_REAR =
            "android.hardware.display.category.REAR";

    /**
     * Display category: All displays, including disabled displays.
     * <p>
@@ -619,11 +636,19 @@ public final class DisplayManager {
        synchronized (mLock) {
            try {
                if (DISPLAY_CATEGORY_PRESENTATION.equals(category)) {
                    addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI);
                    addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_EXTERNAL);
                    addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_OVERLAY);
                    addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_VIRTUAL);
                    addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL);
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI,
                            Display.FLAG_PRESENTATION);
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_EXTERNAL,
                            Display.FLAG_PRESENTATION);
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_OVERLAY,
                            Display.FLAG_PRESENTATION);
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_VIRTUAL,
                            Display.FLAG_PRESENTATION);
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL,
                            Display.FLAG_PRESENTATION);
                } else if (DISPLAY_CATEGORY_REAR.equals(category)) {
                    addDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL,
                            Display.FLAG_REAR);
                } else if (category == null
                        || DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED.equals(category)) {
                    addAllDisplaysLocked(mTempDisplays, displayIds);
@@ -644,15 +669,16 @@ public final class DisplayManager {
        }
    }

    private void addPresentationDisplaysLocked(
            ArrayList<Display> displays, int[] displayIds, int matchType) {
        for (int i = 0; i < displayIds.length; i++) {
            if (displayIds[i] == DEFAULT_DISPLAY) {
    private void addDisplaysLocked(
            ArrayList<Display> displays, int[] displayIds, int matchType, int flagMask) {
        for (int displayId : displayIds) {
            if (displayId == DEFAULT_DISPLAY) {
                continue;
            }
            Display display = getOrCreateDisplayLocked(displayIds[i], true /*assumeValid*/);

            Display display = getOrCreateDisplayLocked(displayId, /* assumeValid= */ true);
            if (display != null
                    && (display.getFlags() & Display.FLAG_PRESENTATION) != 0
                    && (display.getFlags() & flagMask) == flagMask
                    && display.getType() == matchType) {
                displays.add(display);
            }
+11 −0
Original line number Diff line number Diff line
@@ -359,6 +359,17 @@ public final class Display {
     */
    public static final int FLAG_STEAL_TOP_FOCUS_DISABLED = 1 << 12;

    /**
     * Display flag: Indicates that the display is a rear display.
     * <p>
     * This flag identifies complementary displays that are facing away from the user.
     * </p>
     *
     * @hide
     * @see #getFlags()
     */
    public static final int FLAG_REAR = 1 << 13;

    /**
     * Display flag: Indicates that the contents of the display should not be scaled
     * to fit the physical screen dimensions.  Used for development only to emulate
+3 −0
Original line number Diff line number Diff line
@@ -906,6 +906,9 @@ public final class DisplayInfo implements Parcelable {
        if ((flags & Display.FLAG_TOUCH_FEEDBACK_DISABLED) != 0) {
            result.append(", FLAG_TOUCH_FEEDBACK_DISABLED");
        }
        if ((flags & Display.FLAG_REAR) != 0) {
            result.append(", FLAG_REAR_DISPLAY");
        }
        return result.toString();
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ class DeviceStateToLayoutMap {
                final int state = l.getState().intValue();
                final Layout layout = createLayout(state);
                for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
                    assert layout != null;
                    Layout.Display display = layout.createDisplayLocked(
                            DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
                            d.isDefaultDisplay(),
+18 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceControl;

import com.android.server.display.layout.Layout;
import com.android.server.wm.utils.InsetUtils;

import java.io.PrintWriter;
@@ -152,6 +153,10 @@ final class LogicalDisplay {
    // the {@link mIsEnabled} is changing, or the underlying mPrimiaryDisplayDevice is changing.
    private boolean mIsInTransition;

    // Indicates the position of the display, POSITION_UNKNOWN could mean it hasn't been specified,
    // or this is a virtual display etc.
    private int mPosition = Layout.Display.POSITION_UNKNOWN;

    /**
     * The ID of the brightness throttling data that should be used. This can change e.g. in
     * concurrent displays mode in which a stricter brightness throttling policy might need to be
@@ -170,6 +175,13 @@ final class LogicalDisplay {
        mBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID;
    }

    public void setPositionLocked(int position) {
        mPosition = position;
    }
    public int getPositionLocked() {
        return mPosition;
    }

    /**
     * Gets the logical display id of this logical display.
     *
@@ -424,6 +436,11 @@ final class LogicalDisplay {
            mBaseDisplayInfo.roundedCorners = deviceInfo.roundedCorners;
            mBaseDisplayInfo.installOrientation = deviceInfo.installOrientation;
            mBaseDisplayInfo.displayShape = deviceInfo.displayShape;

            if (mPosition == Layout.Display.POSITION_REAR) {
                mBaseDisplayInfo.flags |= Display.FLAG_REAR;
            }

            mPrimaryDisplayDeviceInfo = deviceInfo;
            mInfo.set(null);
        }
@@ -814,6 +831,7 @@ final class LogicalDisplay {
        pw.println("mIsEnabled=" + mIsEnabled);
        pw.println("mIsInTransition=" + mIsInTransition);
        pw.println("mLayerStack=" + mLayerStack);
        pw.println("mPosition=" + mPosition);
        pw.println("mHasContent=" + mHasContent);
        pw.println("mDesiredDisplayModeSpecs={" + mDesiredDisplayModeSpecs + "}");
        pw.println("mRequestedColorMode=" + mRequestedColorMode);
Loading