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

Commit 54755995 authored by Sean Stout's avatar Sean Stout Committed by Android (Google) Code Review
Browse files

Merge "Introduce DisplayGroup"

parents ec817350 a9f63583
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -326,6 +326,15 @@ public final class DisplayManager {
    @TestApi
    public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1 << 10;

    /**
     * Virtual display flags: Indicates that the display should not be a part of the default
     * DisplayGroup and instead be part of a new DisplayGroup.
     *
     * @see #createVirtualDisplay
     * @hide
     */
    public static final int VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP = 1 << 11;

    /** @hide */
    public DisplayManager(Context context) {
        mContext = context;
+9 −0
Original line number Diff line number Diff line
@@ -261,6 +261,15 @@ public final class Display {
    @TestApi
    public static final int FLAG_TRUSTED = 1 << 7;

    /**
     * Flag: Indicates that the display should not be a part of the default DisplayGroup and
     * instead be part of a new DisplayGroup.
     *
     * @hide
     * @see #getFlags()
     */
    public static final int FLAG_OWN_DISPLAY_GROUP = 1 << 8;

    /**
     * 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
+8 −0
Original line number Diff line number Diff line
@@ -129,6 +129,14 @@ final class DisplayDeviceInfo {
     */
    public static final int FLAG_TRUSTED = 1 << 13;

    /**
     * Flag: Indicates that the display should not be a part of the default {@link DisplayGroup} and
     * instead be part of a new {@link DisplayGroup}.
     *
     * @hide
     */
    public static final int FLAG_OWN_DISPLAY_GROUP = 1 << 14;

    /**
     * Touch attachment: Display does not receive touch.
     */
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.display;

import java.util.ArrayList;
import java.util.List;

/**
 * Represents a collection of {@link LogicalDisplay}s which act in unison for certain behaviors and
 * operations.
 */
public class DisplayGroup {

    final List<LogicalDisplay> mDisplays = new ArrayList<>();

    void addDisplay(LogicalDisplay display) {
        if (!mDisplays.contains(display)) {
            mDisplays.add(display);
        }
    }

    boolean removeDisplay(LogicalDisplay display) {
        return mDisplays.remove(display);
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
@@ -2024,6 +2025,9 @@ public final class DisplayManagerService extends SystemService {
            if ((flags & VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY) != 0) {
                flags &= ~VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
            }
            if ((flags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) {
                flags &= ~VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP;
            }

            if (projection != null) {
                try {
@@ -2062,6 +2066,14 @@ public final class DisplayManagerService extends SystemService {
                }
            }

            if (callingUid != Process.SYSTEM_UID
                    && (flags & VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP) != 0) {
                if (!checkCallingPermission(ADD_TRUSTED_DISPLAY, "createVirtualDisplay()")) {
                    throw new SecurityException("Requires ADD_TRUSTED_DISPLAY permission to "
                            + "create a virtual display which is not in the default DisplayGroup.");
                }
            }

            if ((flags & VIRTUAL_DISPLAY_FLAG_TRUSTED) == 0) {
                flags &= ~VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
            }
Loading