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

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

Merge "Make FLAG_LAYOUT_NO_LIMITS compatible"

parents f6a91b70 e5a898a9
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.view;
package android.view;


import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
import static android.view.InsetsController.ANIMATION_TYPE_SHOW;
import static android.view.InsetsController.AnimationType;
import static android.view.InsetsController.AnimationType;
import static android.view.InsetsController.DEBUG;
import static android.view.InsetsController.DEBUG;
@@ -24,6 +25,7 @@ import static android.view.InsetsState.ISIDE_LEFT;
import static android.view.InsetsState.ISIDE_RIGHT;
import static android.view.InsetsState.ISIDE_RIGHT;
import static android.view.InsetsState.ISIDE_TOP;
import static android.view.InsetsState.ISIDE_TOP;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;


import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;


@@ -308,8 +310,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
                false /* isScreenRound */,
                false /* isScreenRound */,
                false /* alwaysConsumeSystemBars */, null /* displayCutout */,
                false /* alwaysConsumeSystemBars */, null /* displayCutout */,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
                0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, typeSideMap)
                0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
               .getInsets(mTypes);
                WINDOWING_MODE_UNDEFINED, typeSideMap).getInsets(mTypes);
    }
    }


    private Insets sanitize(Insets insets) {
    private Insets sanitize(Insets insets) {
+9 −4
Original line number Original line Diff line number Diff line
@@ -500,9 +500,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    /** Pending control request that is waiting on IME to be ready to be shown */
    /** Pending control request that is waiting on IME to be ready to be shown */
    private PendingControlRequest mPendingImeControlRequest;
    private PendingControlRequest mPendingImeControlRequest;


    private int mWindowType;
    private int mLastLegacySoftInputMode;
    private int mLastLegacySoftInputMode;
    private int mLastLegacyWindowFlags;
    private int mLastLegacyWindowFlags;
    private int mLastLegacySystemUiFlags;
    private int mLastLegacySystemUiFlags;
    private int mLastWindowingMode;
    private DisplayCutout mLastDisplayCutout;
    private DisplayCutout mLastDisplayCutout;
    private boolean mStartingAnimation;
    private boolean mStartingAnimation;
    private int mCaptionInsetsHeight = 0;
    private int mCaptionInsetsHeight = 0;
@@ -571,7 +573,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            WindowInsets insets = state.calculateInsets(mFrame, mState /* ignoringVisibilityState*/,
            WindowInsets insets = state.calculateInsets(mFrame, mState /* ignoringVisibilityState*/,
                    mLastInsets.isRound(), mLastInsets.shouldAlwaysConsumeSystemBars(),
                    mLastInsets.isRound(), mLastInsets.shouldAlwaysConsumeSystemBars(),
                    mLastDisplayCutout, mLastLegacySoftInputMode, mLastLegacyWindowFlags,
                    mLastDisplayCutout, mLastLegacySoftInputMode, mLastLegacyWindowFlags,
                    mLastLegacySystemUiFlags, null /* typeSideMap */);
                    mLastLegacySystemUiFlags, mWindowType, mLastWindowingMode,
                    null /* typeSideMap */);
            mHost.dispatchWindowInsetsAnimationProgress(insets, mUnmodifiableTmpRunningAnims);
            mHost.dispatchWindowInsetsAnimationProgress(insets, mUnmodifiableTmpRunningAnims);
            if (DEBUG) {
            if (DEBUG) {
                for (WindowInsetsAnimation anim : mUnmodifiableTmpRunningAnims) {
                for (WindowInsetsAnimation anim : mUnmodifiableTmpRunningAnims) {
@@ -709,9 +712,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
     * @see InsetsState#calculateInsets
     * @see InsetsState#calculateInsets
     */
     */
    @VisibleForTesting
    @VisibleForTesting
    public WindowInsets calculateInsets(boolean isScreenRound,
    public WindowInsets calculateInsets(boolean isScreenRound, boolean alwaysConsumeSystemBars,
            boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            DisplayCutout cutout, int windowType, int windowingMode,
            int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags) {
            int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags) {
        mWindowType = windowType;
        mLastWindowingMode = windowingMode;
        mLastLegacySoftInputMode = legacySoftInputMode;
        mLastLegacySoftInputMode = legacySoftInputMode;
        mLastLegacyWindowFlags = legacyWindowFlags;
        mLastLegacyWindowFlags = legacyWindowFlags;
        mLastLegacySystemUiFlags = legacySystemUiFlags;
        mLastLegacySystemUiFlags = legacySystemUiFlags;
@@ -719,7 +724,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        mLastInsets = mState.calculateInsets(mFrame, null /* ignoringVisibilityState*/,
        mLastInsets = mState.calculateInsets(mFrame, null /* ignoringVisibilityState*/,
                isScreenRound, alwaysConsumeSystemBars, cutout,
                isScreenRound, alwaysConsumeSystemBars, cutout,
                legacySoftInputMode, legacyWindowFlags, legacySystemUiFlags,
                legacySoftInputMode, legacyWindowFlags, legacySystemUiFlags,
                null /* typeSideMap */);
                windowType, windowingMode, null /* typeSideMap */);
        return mLastInsets;
        return mLastInsets;
    }
    }


+14 −0
Original line number Original line Diff line number Diff line
@@ -30,11 +30,15 @@ import static android.view.WindowInsets.Type.isVisibleInsetsType;
import static android.view.WindowInsets.Type.statusBars;
import static android.view.WindowInsets.Type.statusBars;
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;


import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.WindowConfiguration;
import android.graphics.Insets;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcel;
@@ -174,6 +178,7 @@ public class InsetsState implements Parcelable {
    public WindowInsets calculateInsets(Rect frame, @Nullable InsetsState ignoringVisibilityState,
    public WindowInsets calculateInsets(Rect frame, @Nullable InsetsState ignoringVisibilityState,
            boolean isScreenRound, boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            boolean isScreenRound, boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags,
            int legacySoftInputMode, int legacyWindowFlags, int legacySystemUiFlags,
            int windowType, @WindowConfiguration.WindowingMode int windowingMode,
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
        Insets[] typeInsetsMap = new Insets[Type.SIZE];
        Insets[] typeInsetsMap = new Insets[Type.SIZE];
        Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
        Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
@@ -228,6 +233,9 @@ public class InsetsState implements Parcelable {
        if ((legacyWindowFlags & FLAG_FULLSCREEN) != 0) {
        if ((legacyWindowFlags & FLAG_FULLSCREEN) != 0) {
            compatInsetsTypes &= ~statusBars();
            compatInsetsTypes &= ~statusBars();
        }
        }
        if (clearCompatInsets(windowType, legacyWindowFlags, windowingMode)) {
            compatInsetsTypes = 0;
        }


        return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound,
        return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound,
                alwaysConsumeSystemBars, cutout, compatInsetsTypes,
                alwaysConsumeSystemBars, cutout, compatInsetsTypes,
@@ -449,6 +457,12 @@ public class InsetsState implements Parcelable {
        mSources[source.getType()] = source;
        mSources[source.getType()] = source;
    }
    }


    public static boolean clearCompatInsets(int windowType, int windowFlags, int windowingMode) {
        return (windowFlags & FLAG_LAYOUT_NO_LIMITS) != 0
                && windowType != TYPE_WALLPAPER && windowType != TYPE_SYSTEM_ERROR
                && !WindowConfiguration.inMultiWindowMode(windowingMode);
    }

    public static @InternalInsetsType ArraySet<Integer> toInternalType(@InsetsType int types) {
    public static @InternalInsetsType ArraySet<Integer> toInternalType(@InsetsType int types) {
        final ArraySet<Integer> result = new ArraySet<>();
        final ArraySet<Integer> result = new ArraySet<>();
        if ((types & Type.STATUS_BARS) != 0) {
        if ((types & Type.STATUS_BARS) != 0) {
+4 −2
Original line number Original line Diff line number Diff line
@@ -2253,9 +2253,11 @@ public final class ViewRootImpl implements ViewParent,


    /* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
    /* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
        if (mLastWindowInsets == null || forceConstruct) {
        if (mLastWindowInsets == null || forceConstruct) {
            final Configuration config = mContext.getResources().getConfiguration();
            mLastWindowInsets = mInsetsController.calculateInsets(
            mLastWindowInsets = mInsetsController.calculateInsets(
                    mContext.getResources().getConfiguration().isScreenRound(),
                    config.isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars,
                    mAttachInfo.mAlwaysConsumeSystemBars, mPendingDisplayCutout.get(),
                    mPendingDisplayCutout.get(), mWindowAttributes.type,
                    config.windowConfiguration.getWindowingMode(),
                    mWindowAttributes.softInputMode, mWindowAttributes.flags,
                    mWindowAttributes.softInputMode, mWindowAttributes.flags,
                    (mWindowAttributes.systemUiVisibility
                    (mWindowAttributes.systemUiVisibility
                            | mWindowAttributes.subtreeSystemUiVisibility));
                            | mWindowAttributes.subtreeSystemUiVisibility));
+6 −4
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.UiContext;
import android.app.ResourcesManager;
import android.app.ResourcesManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Insets;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
@@ -271,13 +272,14 @@ public final class WindowManagerImpl implements WindowManager {
            final boolean alwaysConsumeSystemBars = WindowManagerGlobal.getWindowManagerService()
            final boolean alwaysConsumeSystemBars = WindowManagerGlobal.getWindowManagerService()
                    .getWindowInsets(attrs, mContext.getDisplayId(), systemWindowInsets,
                    .getWindowInsets(attrs, mContext.getDisplayId(), systemWindowInsets,
                    stableInsets, displayCutout, insetsState);
                    stableInsets, displayCutout, insetsState);
            final boolean isScreenRound =
            final Configuration config = mContext.getResources().getConfiguration();
                    mContext.getResources().getConfiguration().isScreenRound();
            final boolean isScreenRound = config.isScreenRound();
            final int windowingMode = config.windowConfiguration.getWindowingMode();
            if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
            if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
                return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState*/,
                return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState*/,
                        isScreenRound, alwaysConsumeSystemBars, displayCutout.get(),
                        isScreenRound, alwaysConsumeSystemBars, displayCutout.get(),
                        SOFT_INPUT_ADJUST_NOTHING, attrs.flags,
                        SOFT_INPUT_ADJUST_NOTHING, attrs.flags, SYSTEM_UI_FLAG_VISIBLE, attrs.type,
                        SYSTEM_UI_FLAG_VISIBLE, null /* typeSideMap */);
                        windowingMode, null /* typeSideMap */);
            } else {
            } else {
                return new WindowInsets.Builder()
                return new WindowInsets.Builder()
                        .setAlwaysConsumeSystemBars(alwaysConsumeSystemBars)
                        .setAlwaysConsumeSystemBars(alwaysConsumeSystemBars)
Loading