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

Commit d13e45bf authored by Tiger's avatar Tiger
Browse files

Use insetsRoundedCornerFrame to identify taskbar insets source

Previously, many places considered that the insets source with
ITYPE_EXTRA_NAVIGATION_BAR were provided by taskbar, which were
inaccurate, because ITYPE_EXTRA_NAVIGATION_BAR can be provided by other
sources. Also, we are going to remove internal insets types.

Thus, this CL uses InsetsSource#insetsRoundedCornerFrame to identify
expended taskbar instead, and we don't need to check the height of
taskbar anymore.

Bug: 234093736
Test: atest LetterboxUiControllerTest SizeCompatTests
Change-Id: I5561cade375a326f91a252b98d37d0950b25e00f
parent da896af6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class InsetsSource implements Parcelable {
        return mVisibleFrame == null || !mVisibleFrame.isEmpty();
    }

    public boolean getInsetsRoundedCornerFrame() {
    public boolean insetsRoundedCornerFrame() {
        return mInsetsRoundedCornerFrame;
    }

+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ public class InsetsState implements Parcelable {
        final Rect roundedCornerFrame = new Rect(mRoundedCornerFrame);
        for (int i = mSources.size() - 1; i >= 0; i--) {
            final InsetsSource source = mSources.valueAt(i);
            if (source.getInsetsRoundedCornerFrame()) {
            if (source.insetsRoundedCornerFrame()) {
                final Insets insets = source.calculateInsets(roundedCornerFrame, false);
                roundedCornerFrame.inset(insets);
            }
+1 −29
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ package android.view;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.ArraySet;

import java.util.Set;

/**
 * Holds information about how to execute task transition animations.
@@ -36,32 +33,12 @@ public class TaskTransitionSpec implements Parcelable {
     */
    public final int backgroundColor;

    /**
     * TEMPORARY FIELD (b/202383002)
     * TODO: Remove once we use surfaceflinger rounded corners on tasks rather than taskbar overlays
     *  or when shell transitions are fully enabled
     *
     * A set of {@InsetsState.InternalInsetsType}s we want to use as the source to set the bounds
     * of the task during the animation. Used to make sure that task animate above the taskbar.
     * Will also be used to crop to the frame size of the inset source to the inset size to prevent
     * the taskbar rounded corners overlay from being invisible during task transition animation.
     */
    public final Set<Integer> animationBoundInsets;

    public TaskTransitionSpec(
            int backgroundColor, Set<Integer> animationBoundInsets) {
    public TaskTransitionSpec(int backgroundColor) {
        this.backgroundColor = backgroundColor;
        this.animationBoundInsets = animationBoundInsets;
    }

    public TaskTransitionSpec(Parcel in) {
        this.backgroundColor = in.readInt();

        int animationBoundInsetsSize = in.readInt();
        this.animationBoundInsets = new ArraySet<>(animationBoundInsetsSize);
        for (int i = 0; i < animationBoundInsetsSize; i++) {
            this.animationBoundInsets.add(in.readInt());
        }
    }

    @Override
@@ -72,11 +49,6 @@ public class TaskTransitionSpec implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(backgroundColor);

        dest.writeInt(animationBoundInsets.size());
        for (int insetType : animationBoundInsets) {
            dest.writeInt(insetType);
        }
    }

    public static final @android.annotation.NonNull Parcelable.Creator<TaskTransitionSpec>
+8 −11
Original line number Diff line number Diff line
@@ -59,9 +59,6 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
    public static final long TOUCH_ANIMATION_DURATION = 150;
    public static final long TOUCH_RELEASE_ANIMATION_DURATION = 200;

    /** The task bar expanded height. Used to determine whether to insets divider bounds or not. */
    private float mExpandedTaskBarHeight;

    private final int mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    private SplitLayout mSplitLayout;
@@ -216,17 +213,19 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {

    void onInsetsChanged(InsetsState insetsState, boolean animate) {
        mSplitLayout.getDividerBounds(mTempRect);
        final InsetsSource taskBarInsetsSource =
                insetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
        // Only insets the divider bar with task bar when it's expanded so that the rounded corners
        // will be drawn against task bar.
        // But there is no need to do it when IME showing because there are no rounded corners at
        // the bottom. This also avoids the problem of task bar height not changing when IME
        // floating.
        if (!insetsState.isSourceOrDefaultVisible(InsetsSource.ID_IME, WindowInsets.Type.ime())
                && taskBarInsetsSource != null
                && taskBarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight) {
            mTempRect.inset(taskBarInsetsSource.calculateVisibleInsets(mTempRect));
        if (!insetsState.isSourceOrDefaultVisible(InsetsSource.ID_IME, WindowInsets.Type.ime())) {
            for (int i = insetsState.sourceSize() - 1; i >= 0; i--) {
                final InsetsSource source = insetsState.sourceAt(i);
                if (source.getType() == WindowInsets.Type.navigationBars()
                        && source.insetsRoundedCornerFrame()) {
                    mTempRect.inset(source.calculateVisibleInsets(mTempRect));
                }
            }
        }

        if (!mTempRect.equals(mDividerBounds)) {
@@ -251,8 +250,6 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
        mDividerBar = findViewById(R.id.divider_bar);
        mHandle = findViewById(R.id.docked_divider_handle);
        mBackground = findViewById(R.id.docked_divider_background);
        mExpandedTaskBarHeight = getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.taskbar_frame_height);
        mTouchElevation = getResources().getDimensionPixelSize(
                R.dimen.docked_stack_divider_lift_elevation);
        mDoubleTapDetector = new GestureDetector(getContext(), new DoubleTapListener());
+29 −17
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.os.IBinder;
import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.WindowInsets;
import android.window.ITaskOrganizerController;
import android.window.TaskAppearedInfo;
import android.window.WindowContainerToken;
@@ -57,7 +58,6 @@ import com.android.wm.shell.unfold.UnfoldAnimationController;

import java.io.PrintWriter;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
@@ -130,14 +130,34 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {
            new DisplayInsetsController.OnInsetsChangedListener() {
        @Override
        public void insetsChanged(InsetsState insetsState) {
            // Update bounds only when the insets of navigation bar or task bar is changed.
            if (Objects.equals(insetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR),
                    mInsetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR))
                    && Objects.equals(insetsState.peekSource(
                            InsetsState.ITYPE_EXTRA_NAVIGATION_BAR),
                    mInsetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR))) {
            final boolean[] navigationBarChanged = {false};
            InsetsState.traverse(insetsState, mInsetsState, new InsetsState.OnTraverseCallbacks() {
                @Override
                public void onIdMatch(InsetsSource source1, InsetsSource source2) {
                    if (source1.getType() == WindowInsets.Type.navigationBars()
                            && !source1.equals(source2)) {
                        navigationBarChanged[0] = true;
                    }
                }

                @Override
                public void onIdNotFoundInState1(int index2, InsetsSource source2) {
                    if (source2.getType() == WindowInsets.Type.navigationBars()) {
                        navigationBarChanged[0] = true;
                    }
                }

                @Override
                public void onIdNotFoundInState2(int index1, InsetsSource source1) {
                    if (source1.getType() == WindowInsets.Type.navigationBars()) {
                        navigationBarChanged[0] = true;
                    }
                }
            });
            if (!navigationBarChanged[0]) {
                return;
            }
            // Update bounds only when the insets of navigation bar or task bar is changed.
            mInsetsState.set(insetsState);
            updateBounds();
        }
@@ -344,16 +364,8 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {

    private Rect calculateBounds() {
        final Rect bounds = new Rect(0, 0, mDisplayWidth, mDisplayHeight);
        final InsetsSource navBarSource = mInsetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR);
        final InsetsSource taskBarSource = mInsetsState.peekSource(
                InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
        if (navBarSource != null && !navBarSource.getFrame().isEmpty()) {
            bounds.inset(navBarSource.calculateInsets(bounds, false /* ignoreVisibility */));
        } else if (taskBarSource != null && !taskBarSource.getFrame().isEmpty()) {
            bounds.inset(taskBarSource.calculateInsets(bounds, false /* ignoreVisibility */));
        } else {
            bounds.setEmpty();
        }
        bounds.inset(mInsetsState.calculateInsets(
                bounds, WindowInsets.Type.navigationBars(), false /* ignoreVisibility */));
        return bounds;
    }

Loading