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

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

Merge "Ensure that OpenByDefaultDialog is created for config change" into main

parents 604069af a0982ccf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -210,6 +210,11 @@ internal class OpenByDefaultDialog(
        viewHost.relayout(taskBounds.width(), taskBounds.height())
    }

    /**
     * Dismiss dialog and set it to null, so it that it will be re-created on the next opening.
     */
    fun dismiss() = closeMenu()

    /**
     * Handles showing, positioning and tearing down the dialog surface
     */
+24 −3
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.wm.shell.windowdecor;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.windowingModeToString;
import static android.content.pm.ActivityInfo.CONFIG_FONT_SCALE;
import static android.content.pm.ActivityInfo.CONFIG_LOCALE;
import static android.content.pm.ActivityInfo.CONFIG_UI_MODE;
import static android.view.InsetsSource.FLAG_FORCE_CONSUMING;
import static android.view.InsetsSource.FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR;
import static android.view.MotionEvent.ACTION_CANCEL;
@@ -500,9 +503,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                    mResult.mCaptionY + mResult.mCaptionTopPadding);
        }

        if (isOpenByDefaultDialogActive()) {
            mOpenByDefaultDialog.relayout(taskInfo);
        }
        final Configuration oldConfig = mWindowDecorConfig;

        final boolean inFullImmersive = mDesktopUserRepositories.getProfile(taskInfo.userId)
                .isTaskInFullImmersiveState(taskInfo.taskId);
@@ -519,6 +520,26 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                mLockTaskChangeListener.isTaskLocked(),
                /* occludingElementsCalculator = */ () -> getOccludingElements());

        final Configuration newConfig = mRelayoutParams.mWindowDecorConfig;

        boolean configChanged = false;
        if (oldConfig != null && newConfig != null) {
            final int diff = newConfig.diff(oldConfig);
            configChanged = (diff & (CONFIG_UI_MODE | CONFIG_LOCALE | CONFIG_FONT_SCALE)) != 0;
        }

        if (isOpenByDefaultDialogActive()) {
            if (configChanged) {
                // Dismiss the old dialog and create a new one.
                // createOpenByDefaultDialog() will use the new mDecorWindowContext.
                mOpenByDefaultDialog.dismiss();
                createOpenByDefaultDialog();
            } else {
                // No config change, just update layout bounds.
                mOpenByDefaultDialog.relayout(taskInfo);
            }
        }

        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
        final WindowContainerTransaction wct = new WindowContainerTransaction();
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    SurfaceControl mDecorationContainerSurface;

    private WindowDecorViewHost mViewHost;
    private Configuration mWindowDecorConfig;
    protected Configuration mWindowDecorConfig;
    TaskDragResizer mTaskDragResizer;
    boolean mIsCaptionVisible;

+21 −1
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.wm.shell.windowdecor.caption
import android.app.ActivityManager.RunningTaskInfo
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo.CONFIG_FONT_SCALE
import android.content.pm.ActivityInfo.CONFIG_LOCALE
import android.content.pm.ActivityInfo.CONFIG_UI_MODE
import android.graphics.Point
import android.graphics.PointF
import android.graphics.Rect
@@ -176,6 +179,14 @@ class AppHandleController(
            traceTag = Trace.TRACE_TAG_WINDOW_MANAGER,
            name = "AppHandleController#relayout",
        ) {
            // Check for relevant configuration changes
            val oldConfig = this.taskInfo.configuration
            val newConfig = params.runningTaskInfo.configuration
            val diff = newConfig.diff(oldConfig)
            // Check for UI mode (dark/light), locale, or font scale changes
            val configChanged =
                (diff and (CONFIG_UI_MODE or CONFIG_LOCALE or CONFIG_FONT_SCALE)) != 0

            val captionLayout =
                super.relayout(
                    params,
@@ -193,7 +204,16 @@ class AppHandleController(
                captionLayout.captionX,
                captionLayout.captionY,
            )

            if (configChanged && isOpenByDefaultDialogActive) {
                // Config changed, so destroy the old dialog and create a new one.
                // The new one will inflate with the correct resources.
                openByDefaultDialog?.dismiss() // Triggers onDialogDismissed, setting it to null
                createOpenByDefaultDialog()
            } else {
                // No config change, just relayout the existing dialog for size/position changes.
                openByDefaultDialog?.relayout(taskInfo)
            }

            updateViewHolder(captionLayout)

+22 −1
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.wm.shell.windowdecor.caption
import android.app.ActivityManager.RunningTaskInfo
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo.CONFIG_FONT_SCALE
import android.content.pm.ActivityInfo.CONFIG_LOCALE
import android.content.pm.ActivityInfo.CONFIG_UI_MODE
import android.graphics.Point
import android.graphics.Rect
import android.os.Handler
@@ -212,6 +215,14 @@ class AppHeaderController(
                onMaximizeButtonHoverExit()
            }

            // Check for relevant configuration changes
            val oldConfig = this.taskInfo.configuration
            val newConfig = params.runningTaskInfo.configuration
            val diff = newConfig.diff(oldConfig)
            // Check for UI mode (dark/light), locale, or font scale changes
            val configChanged =
                (diff and (CONFIG_UI_MODE or CONFIG_LOCALE or CONFIG_FONT_SCALE)) != 0

            val captionLayout =
                super.relayout(
                    params,
@@ -231,7 +242,17 @@ class AppHeaderController(
                // to the Header in desktop immersive.
                captionLayout.captionY + captionLayout.captionTopPadding,
            )

            if (configChanged && isOpenByDefaultDialogActive) {
                // Config changed, so destroy the old dialog and create a new one.
                // The new one will inflate with the correct resources.
                openByDefaultDialog?.dismiss() // Triggers onDialogDismissed, setting it to null
                createOpenByDefaultDialog()
            } else {
                // No config change, just relayout the existing dialog for size/position changes.
                openByDefaultDialog?.relayout(taskInfo)
            }

            updateMaximizeMenu(startT)

            updateViewHolder(params.hasGlobalFocus)