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

Commit 08328b6c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "onDisplayBelongToTopologyChanged" into main

* changes:
  Notify DisplayTopology when shouldShowSystemDecors changes
  WM callback to add/remove display in topology
parents e0e6cf98 2257c467
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -475,6 +475,16 @@ public abstract class DisplayManagerInternal {
     */
    public abstract boolean isDisplayReadyForMirroring(int displayId);

    /**
     * Called by {@link com.android.server.wm.WindowManagerService} to notify whether a display
     * should be in the topology.
     * @param displayId The logical ID of the display
     * @param inTopology Whether the display should be in the topology. This being true does not
     *                   guarantee that the display will be in the topology - Display Manager might
     *                   also check other parameters.
     */
    public abstract void onDisplayBelongToTopologyChanged(int displayId, boolean inTopology);

    /**
     * Called by {@link  com.android.server.display.DisplayBackupHelper} when backup files were
     * restored and are ready to be reloaded.
+16 −1
Original line number Diff line number Diff line
@@ -2442,7 +2442,10 @@ public final class DisplayManagerService extends SystemService {
            applyDisplayChangedLocked(display);
        }

        if (mDisplayTopologyCoordinator != null) {
        // The default display should always be added to the topology. Other displays will be added
        // upon calling onDisplayBelongToTopologyChanged().
        if (mDisplayTopologyCoordinator != null
                && display.getDisplayIdLocked() == Display.DEFAULT_DISPLAY) {
            mDisplayTopologyCoordinator.onDisplayAdded(display.getDisplayInfoLocked());
        }
    }
@@ -6036,6 +6039,18 @@ public final class DisplayManagerService extends SystemService {
            return mExternalDisplayPolicy.isDisplayReadyForMirroring(displayId);
        }

        @Override
        public void onDisplayBelongToTopologyChanged(int displayId, boolean inTopology) {
            if (mDisplayTopologyCoordinator == null) {
                return;
            }
            if (inTopology) {
                mDisplayTopologyCoordinator.onDisplayAdded(getDisplayInfo(displayId));
            } else {
                mDisplayTopologyCoordinator.onDisplayRemoved(displayId);
            }
        }

        @Override
        public void reloadTopologies(final int userId) {
            // Reload topologies only if the userId matches the current user id.
+0 −5
Original line number Diff line number Diff line
@@ -267,11 +267,6 @@ class DisplayTopologyCoordinator {
                    + "type is EXTERNAL or OVERLAY and !mIsExtendedDisplayEnabled");
            return false;
        }
        if (info.displayGroupId != Display.DEFAULT_DISPLAY_GROUP) {
            Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because "
                    + "it is not in the default display group");
            return false;
        }
        return true;
    }

+22 −7
Original line number Diff line number Diff line
@@ -3262,12 +3262,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            Slog.e(TAG, "ShouldShowSystemDecors shouldn't be updated when the flag is off.");
        }

        final boolean shouldShowContent;
        if (!allowContentModeSwitch()) {
            return;
        }
        shouldShowContent = mDisplay.canHostTasks();

        final boolean shouldShowContent = mDisplay.canHostTasks();
        if (shouldShowContent == mWmService.mDisplayWindowSettings
                .shouldShowSystemDecorsLocked(this)) {
            return;
@@ -3277,6 +3276,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (!shouldShowContent) {
            clearAllTasksOnDisplay(null /* clearTasksCallback */, false /* isRemovingDisplay */);
        }

        // If the display is allowed to show content, then it belongs to the display topology;
        // vice versa.
        mWmService.mDisplayManagerInternal.onDisplayBelongToTopologyChanged(mDisplayId,
                /* inTopology= */ shouldShowContent);
    }

     /**
@@ -3302,6 +3306,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            return false;
        }

        if (shouldNeverShowSystemDecorations()) {
            return false;
        }

        // TODO(b/391965805): Remove this after introducing FLAG_ALLOW_CONTENT_MODE_SWITCH.
        if ((mDisplay.getFlags() & Display.FLAG_REAR) != 0) {
            return false;
@@ -5666,16 +5674,23 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return type == TRANSIT_OPEN || type == TRANSIT_TO_FRONT;
    }

    /**
     * @see Display#FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
     */
    boolean isSystemDecorationsSupported() {
    private boolean shouldNeverShowSystemDecorations() {
        if (mDisplayId == mWmService.mVr2dDisplayId) {
            // VR virtual display will be used to run and render 2D app within a VR experience.
            return false;
            return true;
        }
        if (!isTrusted()) {
            // Do not show system decorations on untrusted virtual display.
            return true;
        }
        return false;
    }

    /**
     * @see Display#FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
     */
    boolean isSystemDecorationsSupported() {
        if (shouldNeverShowSystemDecorations()) {
            return false;
        }
        if (mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)
+5 −0
Original line number Diff line number Diff line
@@ -240,6 +240,11 @@ class DisplayWindowSettings {
        mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings);
    }

    /**
     * Returns {@code true} if either the display is the default display, or the display is allowed
     * to dynamically add/remove system decorations and the system decorations should be shown on it
     * currently.
     */
    boolean shouldShowSystemDecorsLocked(@NonNull DisplayContent dc) {
        if (dc.getDisplayId() == Display.DEFAULT_DISPLAY) {
            // Default display should show system decors.
Loading