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

Commit 3164ec8d authored by Lingyu Feng's avatar Lingyu Feng Committed by Android (Google) Code Review
Browse files

Merge "Fix incorrect onDisplayChanged transmission before onDisplayAdded" into main

parents 677035ca 09f5f804
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -812,7 +812,7 @@ public final class DisplayManagerService extends SystemService {
            handleMinimalPostProcessingAllowedSettingChange();

            if (mFlags.isDisplayContentModeManagementEnabled()) {
                updateMirrorBuiltInDisplaySettingLocked();
                updateMirrorBuiltInDisplaySettingLocked(/*shouldSendDisplayChangeEvent=*/ true);
            }

            final UserManager userManager = getUserManager();
@@ -868,7 +868,7 @@ public final class DisplayManagerService extends SystemService {
                updateHdrConversionModeSettingsLocked();
            }
            if (mFlags.isDisplayContentModeManagementEnabled()) {
                updateMirrorBuiltInDisplaySettingLocked();
                updateMirrorBuiltInDisplaySettingLocked(/*shouldSendDisplayChangeEvent=*/ false);
            }
        }

@@ -1237,8 +1237,11 @@ public final class DisplayManagerService extends SystemService {
            }

            if (Settings.Secure.getUriFor(MIRROR_BUILT_IN_DISPLAY).equals(uri)) {
                synchronized (mSyncRoot) {
                    if (mFlags.isDisplayContentModeManagementEnabled()) {
                    updateMirrorBuiltInDisplaySettingLocked();
                        updateMirrorBuiltInDisplaySettingLocked(/*shouldSendDisplayChangeEvent=*/
                                true);
                    }
                }
                return;
            }
@@ -1258,8 +1261,7 @@ public final class DisplayManagerService extends SystemService {
                1, UserHandle.USER_CURRENT) != 0);
    }

    private void updateMirrorBuiltInDisplaySettingLocked() {
        synchronized (mSyncRoot) {
    private void updateMirrorBuiltInDisplaySettingLocked(boolean shouldSendDisplayChangeEvent) {
        ContentResolver resolver = mContext.getContentResolver();
        final boolean mirrorBuiltInDisplay = Settings.Secure.getIntForUser(resolver,
                MIRROR_BUILT_IN_DISPLAY, 0, UserHandle.USER_CURRENT) != 0;
@@ -1268,8 +1270,10 @@ public final class DisplayManagerService extends SystemService {
        }
        mMirrorBuiltInDisplay = mirrorBuiltInDisplay;
        if (mFlags.isDisplayContentModeManagementEnabled()) {
                mLogicalDisplayMapper.forEachLocked(this::updateCanHostTasksIfNeededLocked);
            }
            mLogicalDisplayMapper.forEachLocked(logicalDisplay -> {
                    updateCanHostTasksIfNeededLocked(logicalDisplay,
                            shouldSendDisplayChangeEvent);
            });
        }
    }

@@ -2380,7 +2384,7 @@ public final class DisplayManagerService extends SystemService {
                new BrightnessPair(brightnessDefault, brightnessDefault));

        if (mFlags.isDisplayContentModeManagementEnabled()) {
            updateCanHostTasksIfNeededLocked(display);
            updateCanHostTasksIfNeededLocked(display, /*shouldSendDisplayChangeEvent=*/ false);
        }

        DisplayManagerGlobal.invalidateLocalDisplayInfoCaches();
@@ -2703,8 +2707,9 @@ public final class DisplayManagerService extends SystemService {
        }
    }

    private void updateCanHostTasksIfNeededLocked(LogicalDisplay display) {
        if (display.setCanHostTasksLocked(!mMirrorBuiltInDisplay)) {
    private void updateCanHostTasksIfNeededLocked(LogicalDisplay display,
            boolean shouldSendDisplayChangeEvent) {
        if (display.setCanHostTasksLocked(!mMirrorBuiltInDisplay) && shouldSendDisplayChangeEvent) {
            sendDisplayEventIfEnabledLocked(display,
                    DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
        }
+6 −1
Original line number Diff line number Diff line
@@ -3263,7 +3263,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
    }

    private boolean allowContentModeSwitch() {
     /**
      * Note that we only allow displays that are able to show system decorations to use the content
      * mode switch; however, not all displays that are able to show system decorations are allowed
      * to use the content mode switch.
      */
     boolean allowContentModeSwitch() {
        // The default display should always show system decorations.
        if (isDefaultDisplay) {
            return false;
+10 −6
Original line number Diff line number Diff line
@@ -247,12 +247,7 @@ class DisplayWindowSettings {

    void setShouldShowSystemDecorsLocked(@NonNull DisplayContent dc, boolean shouldShow) {
        final boolean changed = (shouldShow != shouldShowSystemDecorsLocked(dc));

        final DisplayInfo displayInfo = dc.getDisplayInfo();
        final SettingsProvider.SettingsEntry overrideSettings =
                mSettingsProvider.getOverrideSettings(displayInfo);
        overrideSettings.mShouldShowSystemDecors = shouldShow;
        mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings);
        setShouldShowSystemDecorsInternalLocked(dc, shouldShow);

        if (enableDisplayContentModeManagement()) {
            if (dc.isDefaultDisplay || dc.isPrivate() || !changed) {
@@ -269,6 +264,15 @@ class DisplayWindowSettings {
        }
    }

     void setShouldShowSystemDecorsInternalLocked(@NonNull DisplayContent dc,
            boolean shouldShow) {
        final DisplayInfo displayInfo = dc.getDisplayInfo();
        final SettingsProvider.SettingsEntry overrideSettings =
                mSettingsProvider.getOverrideSettings(displayInfo);
        overrideSettings.mShouldShowSystemDecors = shouldShow;
        mSettingsProvider.updateOverrideSettings(displayInfo, overrideSettings);
    }

    boolean isHomeSupportedLocked(@NonNull DisplayContent dc) {
        if (dc.getDisplayId() == Display.DEFAULT_DISPLAY) {
            // Default display should show home.
+6 −0
Original line number Diff line number Diff line
@@ -2775,6 +2775,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                return;
            }

            if (enableDisplayContentModeManagement() && display.allowContentModeSwitch()) {
                mWindowManager.mDisplayWindowSettings
                        .setShouldShowSystemDecorsInternalLocked(display,
                                display.mDisplay.canHostTasks());
            }

            startSystemDecorations(display, "displayAdded");

            // Drop any cached DisplayInfos associated with this display id - the values are now