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

Commit 609c7598 authored by Lingyu Feng's avatar Lingyu Feng
Browse files

Update DisplayWindowSettings.mShouldShowSystemDecors in setCurrentUser()

During the boot phase, the call to WindowManagerService#setCurrentUser()
triggers DisplayWindowSettingsProvider.setOverrideSettingsForUser(),
which resets all SettingsEntry objects of DisplayWindowSettings to null,
including mShouldShowSystemDecorations.

Because mShouldShowSystemDecorations is set upon onDisplayAdded() and
setCurrentUser() happens afterwards, shouldShowSystemDecorsLocked()
will consistently return false, regardless of the correct value.
This incorrect persists until the next onDisplayChanged() call updates
DisplayWindowSettings.mShouldShowSystemDecors.

This results in the issue where home activity and wallpaper are not
shown on the overlay display after a reboot if the overlay display was
added before the reboot.

This CL fixed this issue by updating
DisplayWindowSettings.mShouldShowSystemDecos after
setOverrideSettingsForUser() in setCurrentUser().

Bug: 409887951
Test: manually
Test: run go/cd-smoke
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Change-Id: I0e9947df10d70c3a47b943226defefbbc26aa9b3
parent 788f683d
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -3323,6 +3323,16 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return true;
        return true;
    }
    }


    void updateShouldShowSystemDecorations() {
        final boolean shouldShow = mDisplay.canHostTasks();
        if (allowContentModeSwitch() &&
                (shouldShow != mWmService.mDisplayWindowSettings
                        .shouldShowSystemDecorsLocked(this))) {
            mWmService.mDisplayWindowSettings
                    .setShouldShowSystemDecorsInternalLocked(this, shouldShow);
        }
    }

    DisplayCutout loadDisplayCutout(int displayWidth, int displayHeight) {
    DisplayCutout loadDisplayCutout(int displayWidth, int displayHeight) {
        if (mDisplayPolicy == null || mInitialDisplayCutout == null) {
        if (mDisplayPolicy == null || mInitialDisplayCutout == null) {
            return null;
            return null;
+1 −5
Original line number Original line Diff line number Diff line
@@ -2747,11 +2747,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            }
            }


            if (ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()) {
            if (ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()) {
                if (display.allowContentModeSwitch()) {
                display.updateShouldShowSystemDecorations();
                    mWindowManager.mDisplayWindowSettings
                            .setShouldShowSystemDecorsInternalLocked(display,
                                    display.mDisplay.canHostTasks());
                }


                final boolean inTopology = mWindowManager.mDisplayWindowSettings
                final boolean inTopology = mWindowManager.mDisplayWindowSettings
                        .shouldShowSystemDecorsLocked(display);
                        .shouldShowSystemDecorsLocked(display);
+14 −2
Original line number Original line Diff line number Diff line
@@ -308,6 +308,7 @@ import android.window.ActivityWindowInfo;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.ClientWindowFrames;
import android.window.ClientWindowFrames;
import android.window.ConfigurationChangeSetting;
import android.window.ConfigurationChangeSetting;
import android.window.DesktopExperienceFlags;
import android.window.DesktopModeFlags;
import android.window.DesktopModeFlags;
import android.window.IGlobalDragListener;
import android.window.IGlobalDragListener;
import android.window.IScreenRecordingCallback;
import android.window.IScreenRecordingCallback;
@@ -3809,13 +3810,24 @@ public class WindowManagerService extends IWindowManager.Stub
            // Notify whether the root docked task exists for the current user
            // Notify whether the root docked task exists for the current user
            final DisplayContent displayContent = getDefaultDisplayContentLocked();
            final DisplayContent displayContent = getDefaultDisplayContentLocked();


            if (mDisplayReady) {
                // If the display is already prepared, update the density.
                // If the display is already prepared, update the density.
                // Otherwise, we'll update it when it's prepared.
                // Otherwise, we'll update it when it's prepared.
            if (mDisplayReady) {
                final int forcedDensity = getForcedDisplayDensityForUserLocked(newUserId);
                final int forcedDensity = getForcedDisplayDensityForUserLocked(newUserId);
                final int targetDensity = forcedDensity != 0
                final int targetDensity = forcedDensity != 0
                        ? forcedDensity : displayContent.getInitialDisplayDensity();
                        ? forcedDensity : displayContent.getInitialDisplayDensity();
                displayContent.setForcedDensity(targetDensity, UserHandle.USER_CURRENT);
                displayContent.setForcedDensity(targetDensity, UserHandle.USER_CURRENT);

                // Because DisplayWindowSettingsProvider.mOverrideSettings has been reset for the
                // new user, we need to update DisplayWindowSettings.mShouldShowSystemDecors to
                // ensure it reflects the latest value.
                if (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()) {
                    final int displayCount = mRoot.mChildren.size();
                    for (int i = 0; i < displayCount; ++i) {
                        final DisplayContent dc = mRoot.mChildren.get(i);
                        dc.updateShouldShowSystemDecorations();
                    }
                }
            }
            }
        }
        }
    }
    }