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

Commit 43b315d0 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Let WindowState apply compat configuration override when needed

For apps without ActivityRecord such as IME, it is necesary to override
the configuration to apply the compat behavior when needed in
WindowState level. This patch apply the corresponding override when the
ActivityRecord doesn't exist.

Bug: 350874546
Test: WindowStateTests
Test: dumpsys window windows to check config
Flag: com.android.window.flags.insets_decoupled_configuration
Change-Id: I32592d55814abf68d1756a724128e2113740354b
parent 7ef1ce6e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ import android.window.InputTransferToken;
import android.window.TaskFpsCallback;
import android.window.TrustedPresentationThresholds;

import com.android.internal.R;
import com.android.window.flags.Flags;

import java.lang.annotation.ElementType;
@@ -3459,6 +3460,13 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_CONSUME_IME_INSETS = 1 << 25;

        /**
         * Flag to indicate that the window has the
         * {@link R.styleable.Window_windowOptOutEdgeToEdgeEnforcement} flag set.
         * @hide
         */
        public static final int PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE = 1 << 26;

        /**
         * Flag to indicate that the window is controlling how it fits window insets on its own.
         * So we don't need to adjust its attributes for fitting window insets.
@@ -3532,6 +3540,7 @@ public interface WindowManager extends ViewManager {
                PRIVATE_FLAG_NOT_MAGNIFIABLE,
                PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
                PRIVATE_FLAG_CONSUME_IME_INSETS,
                PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE,
                PRIVATE_FLAG_FIT_INSETS_CONTROLLED,
                PRIVATE_FLAG_TRUSTED_OVERLAY,
                PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME,
@@ -3635,6 +3644,10 @@ public interface WindowManager extends ViewManager {
                        mask = PRIVATE_FLAG_CONSUME_IME_INSETS,
                        equals = PRIVATE_FLAG_CONSUME_IME_INSETS,
                        name = "CONSUME_IME_INSETS"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE,
                        equals = PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE,
                        name = "OPTOUT_EDGE_TO_EDGE"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_FIT_INSETS_CONTROLLED,
                        equals = PRIVATE_FLAG_FIT_INSETS_CONTROLLED,
+13 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.view;

import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

import android.animation.ValueAnimator;
@@ -26,6 +28,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.HardwareRenderer;
import android.os.Binder;
import android.os.Build;
@@ -45,6 +48,7 @@ import android.window.ITrustedPresentationListener;
import android.window.InputTransferToken;
import android.window.TrustedPresentationThresholds;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.FastPrintWriter;

@@ -356,12 +360,12 @@ public final class WindowManagerGlobal {
        }

        final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params;
        final Context context = view.getContext();
        if (parentWindow != null) {
            parentWindow.adjustLayoutParamsForSubWindow(wparams);
        } else {
            // If there's no parent, then hardware acceleration for this view is
            // set from the application's hardware acceleration setting.
            final Context context = view.getContext();
            if (context != null
                    && (context.getApplicationInfo().flags
                    & ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
@@ -369,6 +373,14 @@ public final class WindowManagerGlobal {
            }
        }

        if (context != null && wparams.type > LAST_APPLICATION_WINDOW) {
            final TypedArray styles = context.obtainStyledAttributes(R.styleable.Window);
            if (styles.getBoolean(R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, false)) {
                wparams.privateFlags |= PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE;
            }
            styles.recycle();
        }

        ViewRootImpl root;
        View panelParentView = null;

+20 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NOT_MAGNIFIABLE;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
@@ -2989,6 +2990,25 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return (mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0;
    }

    @Override
    void resolveOverrideConfiguration(Configuration newParentConfig) {
        super.resolveOverrideConfiguration(newParentConfig);
        if (mActivityRecord != null) {
            // Let the activity decide whether to apply the size override.
            return;
        }
        final Configuration resolvedConfig = getResolvedOverrideConfiguration();
        resolvedConfig.seq = newParentConfig.seq;
        applySizeOverrideIfNeeded(
                getDisplayContent(),
                mSession.mProcess.mInfo,
                newParentConfig,
                resolvedConfig,
                (mAttrs.privateFlags & PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE) != 0,
                false /* hasFixedRotationTransform */,
                false /* hasCompatDisplayInsets */);
    }

    /**
     * @return {@code true} if this window can receive touches based on among other things,
     * windowing state and recents animation state.