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

Commit 919032ef authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Update the Javadoc for the edge-to-edge enforcement" into main

parents eb8dd96d e0d4a5ab
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -765,7 +765,7 @@ package android {
    field public static final int endY = 16844051; // 0x1010513
    field @Deprecated public static final int endYear = 16843133; // 0x101017d
    field public static final int enforceNavigationBarContrast = 16844293; // 0x1010605
    field public static final int enforceStatusBarContrast = 16844292; // 0x1010604
    field @Deprecated public static final int enforceStatusBarContrast = 16844292; // 0x1010604
    field public static final int enterFadeDuration = 16843532; // 0x101030c
    field public static final int entries = 16842930; // 0x10100b2
    field public static final int entryValues = 16843256; // 0x10101f8
@@ -1196,8 +1196,8 @@ package android {
    field public static final int multiprocess = 16842771; // 0x1010013
    field public static final int name = 16842755; // 0x1010003
    field public static final int nativeHeapZeroInitialized = 16844325; // 0x1010625
    field public static final int navigationBarColor = 16843858; // 0x1010452
    field public static final int navigationBarDividerColor = 16844141; // 0x101056d
    field @Deprecated public static final int navigationBarColor = 16843858; // 0x1010452
    field @Deprecated public static final int navigationBarDividerColor = 16844141; // 0x101056d
    field public static final int navigationContentDescription = 16843969; // 0x10104c1
    field public static final int navigationIcon = 16843968; // 0x10104c0
    field public static final int navigationMode = 16843471; // 0x10102cf
@@ -1568,7 +1568,7 @@ package android {
    field public static final int state_single = 16842915; // 0x10100a3
    field public static final int state_window_focused = 16842909; // 0x101009d
    field public static final int staticWallpaperPreview = 16843569; // 0x1010331
    field public static final int statusBarColor = 16843857; // 0x1010451
    field @Deprecated public static final int statusBarColor = 16843857; // 0x1010451
    field public static final int stepSize = 16843078; // 0x1010146
    field public static final int stopWithTask = 16843626; // 0x101036a
    field public static final int streamType = 16843273; // 0x1010209
@@ -1890,6 +1890,7 @@ package android {
    field public static final int windowNoDisplay = 16843294; // 0x101021e
    field public static final int windowNoMoveAnimation = 16844421; // 0x1010685
    field public static final int windowNoTitle = 16842838; // 0x1010056
    field @FlaggedApi("com.android.window.flags.enforce_edge_to_edge") public static final int windowOptOutEdgeToEdgeEnforcement;
    field @Deprecated public static final int windowOverscan = 16843727; // 0x10103cf
    field public static final int windowReenterTransition = 16843951; // 0x10104af
    field public static final int windowReturnTransition = 16843950; // 0x10104ae
@@ -53619,8 +53620,8 @@ package android.view {
    method @NonNull public abstract android.view.LayoutInflater getLayoutInflater();
    method protected final int getLocalFeatures();
    method public android.media.session.MediaController getMediaController();
    method @ColorInt public abstract int getNavigationBarColor();
    method @ColorInt public int getNavigationBarDividerColor();
    method @Deprecated @ColorInt public abstract int getNavigationBarColor();
    method @Deprecated @ColorInt public int getNavigationBarDividerColor();
    method @NonNull public android.window.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method public android.transition.Transition getReenterTransition();
    method public android.transition.Transition getReturnTransition();
@@ -53630,7 +53631,7 @@ package android.view {
    method public android.transition.Transition getSharedElementReenterTransition();
    method public android.transition.Transition getSharedElementReturnTransition();
    method public boolean getSharedElementsUseOverlay();
    method @ColorInt public abstract int getStatusBarColor();
    method @Deprecated @ColorInt public abstract int getStatusBarColor();
    method @NonNull public java.util.List<android.graphics.Rect> getSystemGestureExclusionRects();
    method public long getTransitionBackgroundFadeDuration();
    method public android.transition.TransitionManager getTransitionManager();
@@ -53646,7 +53647,7 @@ package android.view {
    method public abstract boolean isFloating();
    method public boolean isNavigationBarContrastEnforced();
    method public abstract boolean isShortcutKey(int, android.view.KeyEvent);
    method public boolean isStatusBarContrastEnforced();
    method @Deprecated public boolean isStatusBarContrastEnforced();
    method public boolean isWideColorGamut();
    method public final void makeActive();
    method protected abstract void onActive();
@@ -53678,7 +53679,7 @@ package android.view {
    method public abstract void setContentView(android.view.View);
    method public abstract void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
    method public abstract void setDecorCaptionShade(int);
    method public void setDecorFitsSystemWindows(boolean);
    method @Deprecated public void setDecorFitsSystemWindows(boolean);
    method protected void setDefaultWindowFormat(int);
    method @FlaggedApi("com.android.graphics.hwui.flags.limited_hdr") public void setDesiredHdrHeadroom(@FloatRange(from=0.0f, to=10000.0) float);
    method public void setDimAmount(float);
@@ -53700,9 +53701,9 @@ package android.view {
    method public void setLocalFocus(boolean, boolean);
    method public void setLogo(@DrawableRes int);
    method public void setMediaController(android.media.session.MediaController);
    method public abstract void setNavigationBarColor(@ColorInt int);
    method @Deprecated public abstract void setNavigationBarColor(@ColorInt int);
    method public void setNavigationBarContrastEnforced(boolean);
    method public void setNavigationBarDividerColor(@ColorInt int);
    method @Deprecated public void setNavigationBarDividerColor(@ColorInt int);
    method public void setPreferMinimalPostProcessing(boolean);
    method public void setReenterTransition(android.transition.Transition);
    method public abstract void setResizingCaptionDrawable(android.graphics.drawable.Drawable);
@@ -53714,8 +53715,8 @@ package android.view {
    method public void setSharedElementReturnTransition(android.transition.Transition);
    method public void setSharedElementsUseOverlay(boolean);
    method public void setSoftInputMode(int);
    method public abstract void setStatusBarColor(@ColorInt int);
    method public void setStatusBarContrastEnforced(boolean);
    method @Deprecated public abstract void setStatusBarColor(@ColorInt int);
    method @Deprecated public void setStatusBarContrastEnforced(boolean);
    method public void setSustainedPerformanceMode(boolean);
    method public void setSystemGestureExclusionRects(@NonNull java.util.List<android.graphics.Rect>);
    method public abstract void setTitle(CharSequence);
+59 −4
Original line number Diff line number Diff line
@@ -1497,13 +1497,21 @@ public abstract class Window {
     * {@link View#SYSTEM_UI_LAYOUT_FLAGS} as well the
     * {@link WindowManager.LayoutParams#SOFT_INPUT_ADJUST_RESIZE} flag and fits content according
     * to these flags.
     * </p>
     *
     * <p>
     * If set to {@code false}, the framework will not fit the content view to the insets and will
     * just pass through the {@link WindowInsets} to the content view.
     * </p>
     *
     * <p>
     * If the app targets
     * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
     * the behavior will be like setting this to {@code false}, and cannot be changed.
     *
     * @param decorFitsSystemWindows Whether the decor view should fit root-level content views for
     *                               insets.
     * @deprecated Make space in the container views to prevent the critical elements from getting
     *             obscured by {@link WindowInsets.Type#systemBars()} or
     *             {@link WindowInsets.Type#displayCutout()} instead.
     */
    public void setDecorFitsSystemWindows(boolean decorFitsSystemWindows) {
    }
@@ -2597,7 +2605,9 @@ public abstract class Window {

    /**
     * @return the color of the status bar.
     * @deprecated This is no longer needed since the setter is deprecated.
     */
    @Deprecated
    @ColorInt
    public abstract int getStatusBarColor();

@@ -2614,13 +2624,29 @@ public abstract class Window {
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
     * <p>
     * The transitionName for the view background will be "android:status:background".
     * </p>
     *
     * <p>
     * If the color is transparent and the window enforces the status bar contrast, the system
     * will determine whether a scrim is necessary and draw one on behalf of the app to ensure
     * that the status bar has enough contrast with the contents of this app, and set an appropriate
     * effective bar background accordingly.
     *
     * <p>
     * If the app targets
     * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
     * the color will be transparent and cannot be changed.
     *
     * @see #setNavigationBarContrastEnforced
     * @deprecated Draw proper background behind {@link WindowInsets.Type#statusBars()}} instead.
     */
    @Deprecated
    public abstract void setStatusBarColor(@ColorInt int color);

    /**
     * @return the color of the navigation bar.
     * @deprecated This is no longer needed since the setter is deprecated.
     */
    @Deprecated
    @ColorInt
    public abstract int getNavigationBarColor();

@@ -2637,9 +2663,24 @@ public abstract class Window {
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
     * <p>
     * The transitionName for the view background will be "android:navigation:background".
     * </p>
     *
     * <p>
     * If the color is transparent and the window enforces the navigation bar contrast, the system
     * will determine whether a scrim is necessary and draw one on behalf of the app to ensure that
     * the navigation bar has enough contrast with the contents of this app, and set an appropriate
     * effective bar background accordingly.
     *
     * <p>
     * If the app targets
     * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
     * the color will be transparent and cannot be changed.
     *
     * @attr ref android.R.styleable#Window_navigationBarColor
     * @see #setNavigationBarContrastEnforced
     * @deprecated Draw proper background behind {@link WindowInsets.Type#navigationBars()} or
     *             {@link WindowInsets.Type#tappableElement()} instead.
     */
    @Deprecated
    public abstract void setNavigationBarColor(@ColorInt int color);

    /**
@@ -2651,9 +2692,17 @@ public abstract class Window {
     * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
     * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
     *
     * <p>
     * If the app targets
     * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
     * the color will be transparent and cannot be changed.
     *
     * @param dividerColor The color of the thin line.
     * @attr ref android.R.styleable#Window_navigationBarDividerColor
     * @deprecated Draw proper background behind {@link WindowInsets.Type#navigationBars()} or
     *             {@link WindowInsets.Type#tappableElement()} instead.
     */
    @Deprecated
    public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
    }

@@ -2663,7 +2712,9 @@ public abstract class Window {
     * @return The color of the navigation bar divider color.
     * @see #setNavigationBarColor(int)
     * @attr ref android.R.styleable#Window_navigationBarDividerColor
     * @deprecated This is no longer needed since the setter is deprecated.
     */
    @Deprecated
    public @ColorInt int getNavigationBarDividerColor() {
        return 0;
    }
@@ -2682,7 +2733,9 @@ public abstract class Window {
     * @see android.R.attr#enforceStatusBarContrast
     * @see #isStatusBarContrastEnforced
     * @see #setStatusBarColor
     * @deprecated Draw proper background behind {@link WindowInsets.Type#statusBars()}} instead.
     */
    @Deprecated
    public void setStatusBarContrastEnforced(boolean ensureContrast) {
    }

@@ -2697,7 +2750,9 @@ public abstract class Window {
     * @see android.R.attr#enforceStatusBarContrast
     * @see #setStatusBarContrastEnforced
     * @see #setStatusBarColor
     * @deprecated This is not needed since the setter is deprecated.
     */
    @Deprecated
    public boolean isStatusBarContrastEnforced() {
        return false;
    }
+18 −15
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ import android.window.OnBackInvokedDispatcher;
import android.window.ProxyOnBackInvokedDispatcher;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.IconMenuPresenter;
import com.android.internal.view.menu.ListMenuPresenter;
@@ -369,8 +368,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

    boolean mDecorFitsSystemWindows = true;

    @VisibleForTesting
    public final boolean mEdgeToEdgeEnforced;
    private boolean mEdgeToEdgeEnforced;

    private final ProxyOnBackInvokedDispatcher mProxyOnBackInvokedDispatcher;

@@ -390,11 +388,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        mProxyOnBackInvokedDispatcher = new ProxyOnBackInvokedDispatcher(context);
        mAllowFloatingWindowsFillScreen = context.getResources().getBoolean(
                com.android.internal.R.bool.config_allowFloatingWindowsFillScreen);
        mEdgeToEdgeEnforced = isEdgeToEdgeEnforced(context.getApplicationInfo(), true /* local */);
        if (mEdgeToEdgeEnforced) {
            getAttributes().privateFlags |= PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
            mDecorFitsSystemWindows = false;
        }
    }

    /**
@@ -436,15 +429,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     *
     * @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 edge-to-edge is enforced. Otherwise, {@code false}.
     */
    public static boolean isEdgeToEdgeEnforced(ApplicationInfo info, boolean local) {
        return info.targetSdkVersion >= ENFORCE_EDGE_TO_EDGE_SDK_VERSION
    public static boolean isEdgeToEdgeEnforced(ApplicationInfo info, boolean local,
            TypedArray 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.
                                ? CompatChanges.isChangeEnabled(ENFORCE_EDGE_TO_EDGE)
                                // Calling this requires permissions.
                        : info.isChangeEnabled(ENFORCE_EDGE_TO_EDGE)));
                                : info.isChangeEnabled(ENFORCE_EDGE_TO_EDGE))));
    }

    @Override
@@ -2470,6 +2466,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            System.out.println(s);
        }

        mEdgeToEdgeEnforced = isEdgeToEdgeEnforced(
                getContext().getApplicationInfo(), true /* local */, a);
        if (mEdgeToEdgeEnforced) {
            getAttributes().privateFlags |= PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
            mDecorFitsSystemWindows = false;
        }

        mIsFloating = a.getBoolean(R.styleable.Window_windowIsFloating, false);
        int flagsToUpdate = (FLAG_LAYOUT_IN_SCREEN|FLAG_LAYOUT_INSET_DECOR)
                & (~getForcedWindowFlags());
+58 −4
Original line number Diff line number Diff line
@@ -2292,7 +2292,17 @@
             {@link android.R.attr#windowDrawsSystemBarBackgrounds} and the status bar must not
             have been requested to be translucent with
             {@link android.R.attr#windowTranslucentStatus}.
             Corresponds to {@link android.view.Window#setStatusBarColor(int)}. -->
             Corresponds to {@link android.view.Window#setStatusBarColor(int)}.
             <p>If the color is transparent and the window enforces the status bar contrast, the
             system will determine whether a scrim is necessary and draw one on behalf of the app to
             ensure that the status bar has enough contrast with the contents of this app, and set
             an appropriate effective bar background accordingly.
             See: {@link android.R.attr#enforceStatusBarContrast}
             <p>If the app targets
             {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
             this attribute is ignored.
             @deprecated Draw proper background behind
                         {@link android.view.WindowInsets.Type#statusBars()}} instead. -->
        <attr name="statusBarColor" format="color" />
        <!-- The color for the navigation bar. If the color is not opaque, consider setting
@@ -2302,7 +2312,18 @@
             {@link android.R.attr#windowDrawsSystemBarBackgrounds} and the navigation bar must not
             have been requested to be translucent with
             {@link android.R.attr#windowTranslucentNavigation}.
             Corresponds to {@link android.view.Window#setNavigationBarColor(int)}. -->
             Corresponds to {@link android.view.Window#setNavigationBarColor(int)}.
             <p>If the color is transparent and the window enforces the navigation bar contrast, the
             system will determine whether a scrim is necessary and draw one on behalf of the app to
             ensure that the navigation bar has enough contrast with the contents of this app, and
             set an appropriate effective bar background accordingly.
             See: {@link android.R.attr#enforceNavigationBarContrast}
             <p>If the app targets
             {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
             this attribute is ignored.
             @deprecated Draw proper background behind
                         {@link android.view.WindowInsets.Type#navigationBars()} or
                         {@link android.view.WindowInsets.Type#tappableElement()} instead. -->
        <attr name="navigationBarColor" format="color" />
        <!-- Shows a thin line of the specified color between the navigation bar and the app
@@ -2311,7 +2332,13 @@
             {@link android.R.attr#windowDrawsSystemBarBackgrounds} and the navigation bar must not
             have been requested to be translucent with
             {@link android.R.attr#windowTranslucentNavigation}.
             Corresponds to {@link android.view.Window#setNavigationBarDividerColor(int)}. -->
             Corresponds to {@link android.view.Window#setNavigationBarDividerColor(int)}.
             <p>If the app targets
             {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
             this attribute is ignored.
             @deprecated Draw proper background behind
                         {@link android.view.WindowInsets.Type#navigationBars()} or
                         {@link android.view.WindowInsets.Type#tappableElement()} instead. -->
        <attr name="navigationBarDividerColor" format="color" />
        <!-- Sets whether the system should ensure that the status bar has enough
@@ -2327,7 +2354,9 @@
             <p>If the app does not target at least {@link android.os.Build.VERSION_CODES#Q Q},
             this attribute is ignored.
             @see android.view.Window#setStatusBarContrastEnforced -->
             @see android.view.Window#setStatusBarContrastEnforced
             @deprecated Draw proper background behind
                         {@link android.view.WindowInsets.Type#statusBars()}} instead. -->
        <attr name="enforceStatusBarContrast" format="boolean" />
        <!-- Sets whether the system should ensure that the navigation bar has enough
@@ -2483,6 +2512,31 @@
            <!-- The icon is shown unless the launching app specified SPLASH_SCREEN_STYLE_EMPTY -->
            <enum name="icon_preferred" value="1" />
        </attr>
        <!-- Flag indicating whether this window would opt-out the edge-to-edge enforcement.
             <p>If this is false, the edge-to-edge enforcement will be applied to the window if its
             app targets
             {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above.
             The affected behaviors are:
             <ul>
                 <li>The framework will not fit the content view to the insets and will just pass
                 through the {@link android.view.WindowInsets} to the content view, as if calling
                 {@link android.view.Window#setDecorFitsSystemWindows(boolean)} with false.
                 <li>{@link android.view.WindowManager.LayoutParams#layoutInDisplayCutoutMode} of
                 the non-floating windows will be set to {@link
                 android.view.WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS}.
                 Changing it to other values will cause {@link lang.IllegalArgumentException}.
                 <li>The framework will set {@link android.R.attr#statusBarColor},
                 {@link android.R.attr#navigationBarColor}, and
                 {@link android.R.attr#navigationBarDividerColor} to transparent.
             </ul>
             <p>If this is true, the edge-to-edge enforcement won't be applied. However, this
             attribute will be deprecated and disabled in a future SDK level.
             <p>This is false by default. -->
        <attr name="windowOptOutEdgeToEdgeEnforcement" format="boolean"/>
    </declare-styleable>
    <!-- The set of attributes that describe a AlertDialog's theme. -->
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@
    <public name="useBoundsForWidth"/>
    <!-- @FlaggedApi("android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP") -->
    <public name="autoTransact"/>
    <!-- @FlaggedApi("com.android.window.flags.enforce_edge_to_edge") -->
    <public name="windowOptOutEdgeToEdgeEnforcement"/>
  </staging-public-group>

  <staging-public-group type="id" first-id="0x01bc0000">
Loading