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

Commit bb07c9e5 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Disable windowOptOutEdgeToEdgeEnforcement if the app targets SDK 36+"

This reverts commit ca35e71b.

Reason for revert: Droidmonitor created revert due to b/388019616, b/387993099. Will be verifying through ABTD before submission.

Change-Id: Ie5822711db4a1c5a922e3df0d421964ff925457e
parent ca35e71b
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import android.window.TrustedPresentationThresholds;

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

import java.io.FileDescriptor;
@@ -376,8 +375,7 @@ public final class WindowManagerGlobal {

        if (context != null && wparams.type > LAST_APPLICATION_WINDOW) {
            final TypedArray styles = context.obtainStyledAttributes(R.styleable.Window);
            if (PhoneWindow.isOptingOutEdgeToEdgeEnforcement(
                    context.getApplicationInfo(), true /* local */, styles)) {
            if (styles.getBoolean(R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, false)) {
                wparams.privateFlags |= PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE;
            }
            styles.recycle();
+5 −32
Original line number Diff line number Diff line
@@ -183,14 +183,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
    private static final long ENFORCE_EDGE_TO_EDGE = 309578419;

    /**
     * Disable opting out the edge-to-edge enforcement.
     * {@link Build.VERSION_CODES#BAKLAVA} or above.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.BAKLAVA)
    private static final long DISABLE_OPT_OUT_EDGE_TO_EDGE = 377864165;

    /**
     * Override the layout in display cutout mode behavior. This will only apply if the edge to edge
     * is not enforced.
@@ -458,7 +450,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     */
    public static boolean isEdgeToEdgeEnforced(ApplicationInfo info, boolean local,
            TypedArray windowStyle) {
        return !isOptingOutEdgeToEdgeEnforcement(info, local, windowStyle)
        return !windowStyle.getBoolean(R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, false)
                && (info.targetSdkVersion >= ENFORCE_EDGE_TO_EDGE_SDK_VERSION
                        || (Flags.enforceEdgeToEdge() && (local
                                // Calling this doesn't require a permission.
@@ -467,26 +459,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                                : info.isChangeEnabled(ENFORCE_EDGE_TO_EDGE))));
    }

    /**
     * Returns whether the given application is opting out edge-to-edge enforcement.
     *
     * @param info The application to query.
     * @param local Whether this is called from the process of the given application.
     * @param windowStyle The style of the window.
     * @return {@code true} if the edge-to-edge enforcement is opting out. Otherwise, {@code false}.
     */
    public static boolean isOptingOutEdgeToEdgeEnforcement(ApplicationInfo info, boolean local,
            TypedArray windowStyle) {
        final boolean disabled = (Flags.disableOptOutEdgeToEdge() && (local
                // Calling this doesn't require a permission.
                ? CompatChanges.isChangeEnabled(DISABLE_OPT_OUT_EDGE_TO_EDGE)
                // Calling this requires permissions.
                : info.isChangeEnabled(DISABLE_OPT_OUT_EDGE_TO_EDGE)));
        return !disabled && windowStyle.getBoolean(
                R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, false /* default */);

    }

    @Override
    public final void setContainer(Window container) {
        super.setContainer(container);
@@ -2514,7 +2486,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

        TypedArray a = getWindowStyle();
        WindowManager.LayoutParams params = getAttributes();
        ApplicationInfo appInfo = getContext().getApplicationInfo();

        if (false) {
            System.out.println("From style:");
@@ -2526,7 +2497,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            System.out.println(s);
        }

        mEdgeToEdgeEnforced = isEdgeToEdgeEnforced(appInfo, true /* local */, a);
        mEdgeToEdgeEnforced = isEdgeToEdgeEnforced(
                getContext().getApplicationInfo(), true /* local */, a);
        if (mEdgeToEdgeEnforced) {
            getAttributes().privateFlags |= PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
            mDecorFitsSystemWindows = false;
@@ -2535,7 +2507,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            // mNavigationBarColor is not reset here because it might be used to draw the scrim.
        }
        if (CompatChanges.isChangeEnabled(OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE)
                && !isOptingOutEdgeToEdgeEnforcement(appInfo, true /* local */, a)) {
                && !a.getBoolean(R.styleable.Window_windowOptOutEdgeToEdgeEnforcement,
                false /* defValue */)) {
            getAttributes().privateFlags |= PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE;
        }

+2 −3
Original line number Diff line number Diff line
@@ -366,7 +366,6 @@ import com.android.internal.content.ReferrerIntent;
import com.android.internal.os.TimeoutRecord;
import com.android.internal.os.TransferPipe;
import com.android.internal.policy.AttributeCache;
import com.android.internal.policy.PhoneWindow;
import com.android.internal.protolog.ProtoLog;
import com.android.internal.util.XmlUtils;
import com.android.modules.utils.TypedXmlPullParser;
@@ -2018,8 +2017,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    || ent.array.getBoolean(R.styleable.Window_windowShowWallpaper, false);
            mStyleFillsParent = mOccludesParent;
            mNoDisplay = ent.array.getBoolean(R.styleable.Window_windowNoDisplay, false);
            mOptOutEdgeToEdge = PhoneWindow.isOptingOutEdgeToEdgeEnforcement(
                    aInfo.applicationInfo, false /* local */, ent.array);
            mOptOutEdgeToEdge = ent.array.getBoolean(
                    R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, false);
        } else {
            mStyleFillsParent = mOccludesParent = true;
            mNoDisplay = false;