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

Commit 8de5556a authored by Merissa Mitchell's avatar Merissa Mitchell
Browse files

Add configuration.assetsSeq check to equalsForTaskOrganizer

so that changing the system theme color triggers a onTaskInfoChanged
call. This will allow app headers (specifically for Wallpaper & Style
page in Settings app) to update its color accordingly.

This CL also removes a workaround that was added in
I1ebabd7e16d0fa4a71f889564781d28b1b303596 for the Settings page
mentioned above.

This CL also sets windowDecorationViewHolder to null in
CaptionController#releaseViews for WindowDecor2, so that the header gets
reinflated appropriately.

Fixes: 437224867
Bug: 412489198
Flag: EXEMPT bugfix
Test: atest WMShellUnitTests:com.android.wm.shell.windowdecor
Test: Manual - navigate to Wallpaper & Style in Settings > change the
Home screen color > observe that the header changes color along with the
app content. Test with enable_window_decoration_refactor flag off and
on.

Change-Id: I770db40d8c76ad3faa1ca238a9e0c79436a2bb17
parent 7f384b84
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -551,6 +551,7 @@ public class TaskInfo {
                && Objects.equals(displayCutoutInsets, that.displayCutoutInsets)
                && getWindowingMode() == that.getWindowingMode()
                && configuration.uiMode == that.configuration.uiMode
                && configuration.assetsSeq == that.configuration.assetsSeq
                && Objects.equals(taskDescription, that.taskDescription)
                && isFocused == that.isFocused
                && isVisible == that.isVisible
+4 −24
Original line number Diff line number Diff line
@@ -211,26 +211,10 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        // at the same, whereas applying them independently causes flickering. See b/270202228.
        relayout(taskInfo, t, t, true /* applyStartTransactionOnDraw */,
                shouldSetTaskVisibilityPositionAndCrop, hasGlobalFocus, displayExclusionRegion,
                /* inSyncWithTransition= */ false, /* forceReinflation= */ false);
    }

    /** TODO(b/437224867): Remove this workaround for "Wallpaper & Style" bug in Settings */
    void onThemeChanged() {
        final SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        final boolean shouldSetTaskVisibilityPositionAndCrop =
                !mDesktopConfig.isVeiledResizeEnabled()
                        && mTaskDragResizer.isResizingOrAnimating();
        final boolean applyTransactionOnDraw = mTaskInfo.isFreeform();
        relayout(mTaskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                mHasGlobalFocus, mExclusionRegion, /* inSyncWithTransition= */ false,
                /* forceReinflation= */ true);
        if (!applyTransactionOnDraw) {
            t.apply();
        }
                /* inSyncWithTransition= */ false);
    }

    @VisibleForTesting
    /** TODO(b/437224867): Remove forceReinflation param */
    static void updateRelayoutParams(
            RelayoutParams relayoutParams,
            @NonNull Context context,
@@ -243,8 +227,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            boolean hasGlobalFocus,
            @NonNull Region globalExclusionRegion,
            boolean shouldSetBackground,
            boolean inSyncWithTransition,
            boolean forceReinflation) {
            boolean inSyncWithTransition) {
        relayoutParams.reset();
        relayoutParams.mRunningTaskInfo = taskInfo;
        relayoutParams.mLayoutResId = R.layout.caption_window_decor;
@@ -266,7 +249,6 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                || (isStatusBarVisible && !isKeyguardVisibleAndOccluded);
        relayoutParams.mDisplayExclusionRegion.set(globalExclusionRegion);
        relayoutParams.mInSyncWithTransition = inSyncWithTransition;
        relayoutParams.mForceReinflation = forceReinflation;

        if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
            // If the app is requesting to customize the caption bar, allow input to fall
@@ -294,13 +276,11 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
    }

    @SuppressLint("MissingPermission")
    /** TODO(b/437224867): Remove forceReinflation param */
    void relayout(RunningTaskInfo taskInfo,
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus,
            @NonNull Region globalExclusionRegion, boolean inSyncWithTransition,
            boolean forceReinflation) {
            @NonNull Region globalExclusionRegion, boolean inSyncWithTransition) {
        final boolean isFreeform =
                taskInfo.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FREEFORM;
        final boolean isDragResizeable = ENABLE_WINDOWING_SCALED_RESIZING.isTrue()
@@ -315,7 +295,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                mIsKeyguardVisibleAndOccluded,
                mDisplayController.getInsetsState(taskInfo.displayId), hasGlobalFocus,
                globalExclusionRegion, mDesktopConfig.shouldSetBackground(taskInfo),
                inSyncWithTransition, forceReinflation);
                inSyncWithTransition);

        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, getLeash(), mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
+2 −17
Original line number Diff line number Diff line
@@ -273,16 +273,11 @@ constructor(
        decorationContainerSurface?.let { updateDragResizeListenerIfNeeded(it) }
    }

    /**
     * Updates all window decorations, including any existing caption.
     *
     * TODO(b/437224867): Remove forceReinflation param
     */
    /** Updates all window decorations, including any existing caption. */
    override fun relayout(
        taskInfo: RunningTaskInfo,
        hasGlobalFocus: Boolean,
        displayExclusionRegion: Region,
        forceReinflation: Boolean,
    ) {
        val t = surfaceControlTransactionSupplier.invoke()
        // The visibility, crop and position of the task should only be set when a task is
@@ -313,18 +308,13 @@ constructor(
            displayExclusionRegion,
            inSyncWithTransition = false,
            taskSurface,
            forceReinflation = forceReinflation,
        )
        if (!applyTransactionOnDraw) {
            t.apply()
        }
    }

    /**
     * Updates all window decorations, including any existing caption.
     *
     * TODO(b/437224867): Remove forceReinflation param
     */
    /** Updates all window decorations, including any existing caption. */
    fun relayout(
        taskInfo: RunningTaskInfo,
        startT: SurfaceControl.Transaction,
@@ -335,7 +325,6 @@ constructor(
        displayExclusionRegion: Region,
        inSyncWithTransition: Boolean,
        taskSurface: SurfaceControl?,
        forceReinflation: Boolean = false,
    ) =
        traceSection("DefaultWindowDecoration#relayout") {
            if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue) {
@@ -366,7 +355,6 @@ constructor(
                    desktopModeCompatPolicy.shouldExcludeCaptionFromAppBounds(taskInfo),
                    desktopConfig,
                    inSyncWithTransition,
                    forceReinflation,
                )

            val wct = windowContainerTransactionSupplier.invoke()
@@ -402,7 +390,6 @@ constructor(
            decorationContainerSurface?.let { updateDragResizeListenerIfNeeded(it) }
        }

    /** TODO(b/437224867): Remove forceReinflation param */
    private fun getRelayoutParams(
        context: Context,
        taskInfo: RunningTaskInfo,
@@ -415,7 +402,6 @@ constructor(
        shouldExcludeCaptionFromAppBounds: Boolean,
        desktopConfig: DesktopConfig,
        inSyncWithTransition: Boolean,
        forceReinflation: Boolean,
    ): RelayoutParams {
        val captionType =
            if (taskInfo.isFreeform) {
@@ -514,7 +500,6 @@ constructor(
            shouldSetAppBounds = shouldSetAppBounds,
            shouldSetBackground = shouldSetBackground,
            inSyncWithTransition = inSyncWithTransition,
            forceReinflation = forceReinflation,
        )
    }

+1 −9
Original line number Diff line number Diff line
@@ -148,7 +148,6 @@ import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource;
import com.android.wm.shell.shared.desktopmode.DesktopState;
import com.android.wm.shell.shared.split.SplitScreenConstants.SplitPosition;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ConfigurationChangeListener;
import com.android.wm.shell.sysui.KeyguardChangeListener;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
@@ -195,7 +194,7 @@ import java.util.function.Supplier;

public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        FocusTransitionListener, SnapEventHandler,
        LockTaskChangeListener.LockTaskModeChangedListener, ConfigurationChangeListener {
        LockTaskChangeListener.LockTaskModeChangedListener {
    private static final String TAG = "DesktopModeWindowDecorViewModel";

    private final WindowDecorationWrapper.Factory mWindowDecoratioWrapperFactory;
@@ -546,7 +545,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
    @OptIn(markerClass = ExperimentalCoroutinesApi.class)
    private void onInit() {
        mShellController.addKeyguardChangeListener(mDesktopModeKeyguardChangeListener);
        mShellController.addConfigurationChangeListener(this);
        mShellCommandHandler.addDumpCallback(this::dump, this);
        mDisplayInsetsController.addGlobalInsetsChangedListener(
                new DesktopModeOnInsetsChangedListener());
@@ -685,12 +683,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        });
    }

    @Override
    /** TODO(b/437224867): Remove this workaround for "Wallpaper & Style" bug in Settings */
    public void onThemeChanged() {
        forAllWindowDecorations(WindowDecorationWrapper::onThemeChanged);
    }

    private void forAllWindowDecorations(Consumer<WindowDecorationWrapper> callback) {
        forAllWindowDecorations(callback, /* reverseOrder= */ false);
    }
+3 −22
Original line number Diff line number Diff line
@@ -429,22 +429,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final boolean applyTransactionOnDraw = taskInfo.isFreeform();
        relayout(taskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                hasGlobalFocus, displayExclusionRegion, /* inSyncWithTransition= */ false,
                /* forceReinflation= */ false, getLeash());
        if (!applyTransactionOnDraw) {
            t.apply();
        }
    }

    /** TODO(b/437224867): Remove this workaround for "Wallpaper & Style" bug in Settings */
    void onThemeChanged() {
        final SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        final boolean shouldSetTaskVisibilityPositionAndCrop =
                !mDesktopConfig.isVeiledResizeEnabled()
                        && mTaskDragResizer.isResizingOrAnimating();
        final boolean applyTransactionOnDraw = mTaskInfo.isFreeform();
        relayout(mTaskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                mHasGlobalFocus, mExclusionRegion, /* inSyncWithTransition= */ false,
                /* forceReinflation= */ true, getLeash());
                getLeash());
        if (!applyTransactionOnDraw) {
            t.apply();
        }
@@ -467,12 +452,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        updateDragResizeListenerIfNeeded(mDecorationContainerSurface, inFullImmersive);
    }

    /** TODO(b/437224867): Remove forceReinflation param */
    void relayout(ActivityManager.RunningTaskInfo taskInfo,
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus, @NonNull Region displayExclusionRegion,
            boolean inSyncWithTransition, boolean forceReinflation, SurfaceControl taskSurface) {
            boolean inSyncWithTransition, SurfaceControl taskSurface) {
        Trace.beginSection("DesktopModeWindowDecoration#relayout");

        if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue()) {
@@ -520,7 +504,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                        .ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX.isTrue(),
                mDesktopModeCompatPolicy.shouldExcludeCaptionFromAppBounds(taskInfo),
                mDesktopConfig, inSyncWithTransition,
                mLockTaskChangeListener.isTaskLocked(), forceReinflation,
                mLockTaskChangeListener.isTaskLocked(),
                /* occludingElementsCalculator = */ () -> getOccludingElements());

        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
@@ -1013,7 +997,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    }

    @VisibleForTesting
    /** TODO(b/437224867): Remove forceReinflation param */
    static void updateRelayoutParams(
            RelayoutParams relayoutParams,
            Context context,
@@ -1033,7 +1016,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            DesktopConfig desktopConfig,
            boolean inSyncWithTransition,
            boolean isTaskLocked,
            boolean forceReinflation,
            Supplier<List<OccludingElement>> occludingElementsCalculator) {
        final int captionLayoutId = getDesktopModeWindowDecorLayoutId(taskInfo.getWindowingMode());
        final boolean isAppHeader =
@@ -1046,7 +1028,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                taskInfo.getWindowingMode());
        relayoutParams.mCaptionWidthId = getCaptionWidthId(relayoutParams.mLayoutResId);
        relayoutParams.mHasGlobalFocus = hasGlobalFocus;
        relayoutParams.mForceReinflation = forceReinflation;
        relayoutParams.mDisplayExclusionRegion.set(displayExclusionRegion);
        // Allow the handle view to be delayed since the handle is just a small addition to the
        // window, whereas the header cannot be delayed because it is expected to be visible from
Loading