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

Commit da96e372 authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Let insets can still be controlled if its window bounds is moved" into sc-dev am: 1c7a2743

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13784130

Change-Id: I96bb6eb9a8d441f340e4d72fad92a7d0a8bdb3b4
parents 874bc578 1c7a2743
Loading
Loading
Loading
Loading
+28 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Insets;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
@@ -28,6 +29,7 @@ import android.os.Build.VERSION_CODES;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.util.DisplayMetrics;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManager;
@@ -423,12 +425,37 @@ public class CompatibilityInfo implements Parcelable {
        }
        }


        /**
        /**
         * Translate an InsetsState in screen coordinates into the app window's coordinates.
         * Translate an {@link InsetsState} in screen coordinates into the app window's coordinates.
         */
         */
        public void translateInsetsStateInScreenToAppWindow(InsetsState state) {
        public void translateInsetsStateInScreenToAppWindow(InsetsState state) {
            state.scale(applicationInvertedScale);
            state.scale(applicationInvertedScale);
        }
        }


        /**
         * Translate {@link InsetsSourceControl}s in screen coordinates into the app window's
         * coordinates.
         */
        public void translateSourceControlsInScreenToAppWindow(InsetsSourceControl[] controls) {
            if (controls == null) {
                return;
            }
            final float scale = applicationInvertedScale;
            if (scale == 1f) {
                return;
            }
            for (InsetsSourceControl control : controls) {
                if (control == null) {
                    continue;
                }
                final Insets hint = control.getInsetsHint();
                control.setInsetsHint(
                        (int) (scale * hint.left),
                        (int) (scale * hint.top),
                        (int) (scale * hint.right),
                        (int) (scale * hint.bottom));
            }
        }

        /**
        /**
         * Translate a Point in screen coordinates into the app window's coordinates.
         * Translate a Point in screen coordinates into the app window's coordinates.
         */
         */
+92 −44
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ 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;
import static android.view.InsetsState.ISIDE_BOTTOM;
import static android.view.InsetsState.ISIDE_BOTTOM;
import static android.view.InsetsState.ISIDE_FLOATING;
import static android.view.InsetsState.ISIDE_LEFT;
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;
@@ -74,8 +75,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll


    private final WindowInsetsAnimationControlListener mListener;
    private final WindowInsetsAnimationControlListener mListener;
    private final SparseArray<InsetsSourceControl> mControls;
    private final SparseArray<InsetsSourceControl> mControls;
    private final SparseIntArray mTypeSideMap = new SparseIntArray();
    private final SparseSetArray<InsetsSourceControl> mSideControlsMap = new SparseSetArray<>();
    private final SparseSetArray<InsetsSourceControl> mSideSourceMap = new SparseSetArray<>();


    /** @see WindowInsetsAnimationController#getHiddenStateInsets */
    /** @see WindowInsetsAnimationController#getHiddenStateInsets */
    private final Insets mHiddenInsets;
    private final Insets mHiddenInsets;
@@ -104,8 +104,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
    private Boolean mPerceptible;
    private Boolean mPerceptible;


    @VisibleForTesting
    @VisibleForTesting
    public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame,
    public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls,
            InsetsState state, WindowInsetsAnimationControlListener listener,
            @Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
            @InsetsType int types,
            @InsetsType int types,
            InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
            InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
            @AnimationType int animationType, CompatibilityInfo.Translator translator) {
            @AnimationType int animationType, CompatibilityInfo.Translator translator) {
@@ -114,19 +114,30 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        mTypes = types;
        mTypes = types;
        mController = controller;
        mController = controller;
        mInitialInsetsState = new InsetsState(state, true /* copySources */);
        mInitialInsetsState = new InsetsState(state, true /* copySources */);
        if (frame != null) {
            final SparseIntArray typeSideMap = new SparseIntArray();
            mCurrentInsets = getInsetsFromState(mInitialInsetsState, frame, null /* typeSideMap */);
            mCurrentInsets = getInsetsFromState(mInitialInsetsState, frame, null /* typeSideMap */);
        mPendingInsets = mCurrentInsets;
            mHiddenInsets = calculateInsets(mInitialInsetsState, frame, controls, false /* shown */,
            mHiddenInsets = calculateInsets(mInitialInsetsState, frame, controls, false /* shown */,
                    null /* typeSideMap */);
                    null /* typeSideMap */);
            mShownInsets = calculateInsets(mInitialInsetsState, frame, controls, true /* shown */,
            mShownInsets = calculateInsets(mInitialInsetsState, frame, controls, true /* shown */,
                mTypeSideMap);
                    typeSideMap);
            mHasZeroInsetsIme = mShownInsets.bottom == 0 && controlsInternalType(ITYPE_IME);
            mHasZeroInsetsIme = mShownInsets.bottom == 0 && controlsInternalType(ITYPE_IME);
            if (mHasZeroInsetsIme) {
            if (mHasZeroInsetsIme) {
                // IME has shownInsets of ZERO, and can't map to a side by default.
                // IME has shownInsets of ZERO, and can't map to a side by default.
                // Map zero insets IME to bottom, making it a special case of bottom insets.
                // Map zero insets IME to bottom, making it a special case of bottom insets.
            mTypeSideMap.put(ITYPE_IME, ISIDE_BOTTOM);
                typeSideMap.put(ITYPE_IME, ISIDE_BOTTOM);
            }
            buildSideControlsMap(typeSideMap, mSideControlsMap, controls);
        } else {
            // Passing a null frame indicates the caller wants to play the insets animation anyway,
            // no matter the source provides insets to the frame or not.
            mCurrentInsets = calculateInsets(mInitialInsetsState, controls, true /* shown */);
            mHiddenInsets = calculateInsets(null, controls, false /* shown */);
            mShownInsets = calculateInsets(null, controls, true /* shown */);
            mHasZeroInsetsIme = mShownInsets.bottom == 0 && controlsInternalType(ITYPE_IME);
            buildSideControlsMap(mSideControlsMap, controls);
        }
        }
        buildTypeSourcesMap(mTypeSideMap, mSideSourceMap, mControls);
        mPendingInsets = mCurrentInsets;


        mAnimation = new WindowInsetsAnimation(mTypes, interpolator,
        mAnimation = new WindowInsetsAnimation(mTypes, interpolator,
                durationMs);
                durationMs);
@@ -312,32 +323,52 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        proto.end(token);
        proto.end(token);
    }
    }


    WindowInsetsAnimationControlListener getListener() {
        return mListener;
    }

    SparseArray<InsetsSourceControl> getControls() {
    SparseArray<InsetsSourceControl> getControls() {
        return mControls;
        return mControls;
    }
    }


    private Insets getInsetsFromState(InsetsState state, Rect frame,
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
        return state.calculateInsets(frame, null /* ignoringVisibilityState */,
                false /* isScreenRound */, false /* alwaysConsumeSystemBars */,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
                0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
                WINDOWING_MODE_UNDEFINED, typeSideMap).getInsets(mTypes);
    }

    /** Computes the insets relative to the given frame. */
    private Insets calculateInsets(InsetsState state, Rect frame,
    private Insets calculateInsets(InsetsState state, Rect frame,
            SparseArray<InsetsSourceControl> controls, boolean shown,
            SparseArray<InsetsSourceControl> controls, boolean shown,
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
        for (int i = controls.size() - 1; i >= 0; i--) {
        for (int i = controls.size() - 1; i >= 0; i--) {
            final InsetsSourceControl control  = controls.valueAt(i);
            if (control == null) {
                // control may be null if it got revoked.
                // control may be null if it got revoked.
            if (controls.valueAt(i) == null) continue;
                continue;
            state.getSource(controls.valueAt(i).getType()).setVisible(shown);
            }
            state.getSource(control.getType()).setVisible(shown);
        }
        }
        return getInsetsFromState(state, frame, typeSideMap);
        return getInsetsFromState(state, frame, typeSideMap);
    }
    }


    private Insets getInsetsFromState(InsetsState state, Rect frame,
    /** Computes the insets from the insets hints of controls. */
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
    private Insets calculateInsets(InsetsState state, SparseArray<InsetsSourceControl> controls,
        return state.calculateInsets(frame, null /* ignoringVisibilityState */,
            boolean shownOrCurrent) {
                false /* isScreenRound */, false /* alwaysConsumeSystemBars */,
        Insets insets = Insets.NONE;
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
        if (!shownOrCurrent) {
                0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION,
            return insets;
                WINDOWING_MODE_UNDEFINED, typeSideMap).getInsets(mTypes);
        }
        for (int i = controls.size() - 1; i >= 0; i--) {
            final InsetsSourceControl control  = controls.valueAt(i);
            if (control == null) {
                // control may be null if it got revoked.
                continue;
            }
            if (state == null || state.getSource(control.getType()).isVisible()) {
                insets = Insets.max(insets, control.getInsetsHint());
            }
        }
        return insets;
    }
    }


    private Insets sanitize(Insets insets) {
    private Insets sanitize(Insets insets) {
@@ -356,13 +387,13 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll


    private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset,
    private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset,
            ArrayList<SurfaceParams> surfaceParams, @Nullable InsetsState outState, float alpha) {
            ArrayList<SurfaceParams> surfaceParams, @Nullable InsetsState outState, float alpha) {
        ArraySet<InsetsSourceControl> items = mSideSourceMap.get(side);
        final ArraySet<InsetsSourceControl> controls = mSideControlsMap.get(side);
        if (items == null) {
        if (controls == null) {
            return;
            return;
        }
        }
        // TODO: Implement behavior when inset spans over multiple types
        // TODO: Implement behavior when inset spans over multiple types
        for (int i = items.size() - 1; i >= 0; i--) {
        for (int i = controls.size() - 1; i >= 0; i--) {
            final InsetsSourceControl control = items.valueAt(i);
            final InsetsSourceControl control = controls.valueAt(i);
            final InsetsSource source = mInitialInsetsState.getSource(control.getType());
            final InsetsSource source = mInitialInsetsState.getSource(control.getType());
            final SurfaceControl leash = control.getLeash();
            final SurfaceControl leash = control.getLeash();


@@ -371,7 +402,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame);
            addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame);


            final boolean visible = mHasZeroInsetsIme && side == ISIDE_BOTTOM
            final boolean visible = mHasZeroInsetsIme && side == ISIDE_BOTTOM
                    ? (mAnimationType == ANIMATION_TYPE_SHOW ? true : !mFinished)
                    ? (mAnimationType == ANIMATION_TYPE_SHOW || !mFinished)
                    : inset != 0;
                    : inset != 0;


            if (outState != null) {
            if (outState != null) {
@@ -391,32 +422,32 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        }
        }
    }
    }


    private void addTranslationToMatrix(@InternalInsetsSide int side, int inset, Matrix m,
    private void addTranslationToMatrix(@InternalInsetsSide int side, int offset, Matrix m,
            Rect frame) {
            Rect frame) {
        final float surfaceOffset = mTranslator != null
        final float surfaceOffset = mTranslator != null
                ? mTranslator.translateLengthInAppWindowToScreen(inset) : inset;
                ? mTranslator.translateLengthInAppWindowToScreen(offset) : offset;
        switch (side) {
        switch (side) {
            case ISIDE_LEFT:
            case ISIDE_LEFT:
                m.postTranslate(-surfaceOffset, 0);
                m.postTranslate(-surfaceOffset, 0);
                frame.offset(-inset, 0);
                frame.offset(-offset, 0);
                break;
                break;
            case ISIDE_TOP:
            case ISIDE_TOP:
                m.postTranslate(0, -surfaceOffset);
                m.postTranslate(0, -surfaceOffset);
                frame.offset(0, -inset);
                frame.offset(0, -offset);
                break;
                break;
            case ISIDE_RIGHT:
            case ISIDE_RIGHT:
                m.postTranslate(surfaceOffset, 0);
                m.postTranslate(surfaceOffset, 0);
                frame.offset(inset, 0);
                frame.offset(offset, 0);
                break;
                break;
            case ISIDE_BOTTOM:
            case ISIDE_BOTTOM:
                m.postTranslate(0, surfaceOffset);
                m.postTranslate(0, surfaceOffset);
                frame.offset(0, inset);
                frame.offset(0, offset);
                break;
                break;
        }
        }
    }
    }


    private static void buildTypeSourcesMap(SparseIntArray typeSideMap,
    private static void buildSideControlsMap(SparseIntArray typeSideMap,
            SparseSetArray<InsetsSourceControl> sideSourcesMap,
            SparseSetArray<InsetsSourceControl> sideControlsMap,
            SparseArray<InsetsSourceControl> controls) {
            SparseArray<InsetsSourceControl> controls) {
        for (int i = typeSideMap.size() - 1; i >= 0; i--) {
        for (int i = typeSideMap.size() - 1; i >= 0; i--) {
            final int type = typeSideMap.keyAt(i);
            final int type = typeSideMap.keyAt(i);
@@ -427,7 +458,24 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
                // there can be some null controllers.
                // there can be some null controllers.
                continue;
                continue;
            }
            }
            sideSourcesMap.add(side, control);
            sideControlsMap.add(side, control);
        }
    }

    private static void buildSideControlsMap(
            SparseSetArray<InsetsSourceControl> sideControlsMap,
            SparseArray<InsetsSourceControl> controls) {
        for (int i = controls.size() - 1; i >= 0; i--) {
            final InsetsSourceControl control  = controls.valueAt(i);
            if (control == null) {
                // control may be null if it got revoked.
                continue;
            }
            @InternalInsetsSide int side = InsetsState.getInsetSide(control.getInsetsHint());
            if (side == ISIDE_FLOATING && control.getType() == ITYPE_IME) {
                side = ISIDE_BOTTOM;
            }
            sideControlsMap.add(side, control);
        }
        }
    }
    }
}
}
+3 −2
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.view.InsetsController.DEBUG;
import static android.view.InsetsController.DEBUG;
import static android.view.SyncRtSurfaceTransactionApplier.applyParams;
import static android.view.SyncRtSurfaceTransactionApplier.applyParams;


import android.annotation.Nullable;
import android.annotation.UiThread;
import android.annotation.UiThread;
import android.content.res.CompatibilityInfo;
import android.content.res.CompatibilityInfo;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -100,8 +101,8 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
    };
    };


    @UiThread
    @UiThread
    public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls, Rect frame,
    public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls,
            InsetsState state, WindowInsetsAnimationControlListener listener,
            @Nullable Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener,
            @InsetsType int types,
            @InsetsType int types,
            InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
            InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator,
            @AnimationType int animationType, CompatibilityInfo.Translator translator,
            @AnimationType int animationType, CompatibilityInfo.Translator translator,
+8 −5
Original line number Original line Diff line number Diff line
@@ -837,9 +837,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            PendingControlRequest pendingRequest = mPendingImeControlRequest;
            PendingControlRequest pendingRequest = mPendingImeControlRequest;
            mPendingImeControlRequest = null;
            mPendingImeControlRequest = null;
            mHandler.removeCallbacks(mPendingControlTimeout);
            mHandler.removeCallbacks(mPendingControlTimeout);

            // We are about to playing the default animation. Passing a null frame indicates the
            // controlled types should be animated regardless of the frame.
            controlAnimationUnchecked(
            controlAnimationUnchecked(
                    pendingRequest.types, pendingRequest.cancellationSignal,
                    pendingRequest.types, pendingRequest.cancellationSignal,
                    pendingRequest.listener, mFrame,
                    pendingRequest.listener, null /* frame */,
                    true /* fromIme */, pendingRequest.durationMs, pendingRequest.interpolator,
                    true /* fromIme */, pendingRequest.durationMs, pendingRequest.interpolator,
                    pendingRequest.animationType,
                    pendingRequest.animationType,
                    pendingRequest.layoutInsetsDuringAnimation,
                    pendingRequest.layoutInsetsDuringAnimation,
@@ -934,7 +937,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation


    private void controlAnimationUnchecked(@InsetsType int types,
    private void controlAnimationUnchecked(@InsetsType int types,
            @Nullable CancellationSignal cancellationSignal,
            @Nullable CancellationSignal cancellationSignal,
            WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme,
            WindowInsetsAnimationControlListener listener, @Nullable Rect frame, boolean fromIme,
            long durationMs, Interpolator interpolator,
            long durationMs, Interpolator interpolator,
            @AnimationType int animationType,
            @AnimationType int animationType,
            @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
            @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
@@ -1358,10 +1361,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                show, hasAnimationCallbacks, types, skipAnim || mAnimationsDisabled,
                show, hasAnimationCallbacks, types, skipAnim || mAnimationsDisabled,
                mHost.dipToPx(InternalAnimationControlListener.FLOATING_IME_BOTTOM_INSET));
                mHost.dipToPx(InternalAnimationControlListener.FLOATING_IME_BOTTOM_INSET));


        // Show/hide animations always need to be relative to the display frame, in order that shown
        // We are about to playing the default animation (show/hide). Passing a null frame indicates
        // and hidden state insets are correct.
        // the controlled types should be animated regardless of the frame.
        controlAnimationUnchecked(
        controlAnimationUnchecked(
                types, null /* cancellationSignal */, listener, mState.getDisplayFrame(), fromIme,
                types, null /* cancellationSignal */, listener, null /* frame */, fromIme,
                listener.getDurationMs(), listener.getInterpolator(),
                listener.getDurationMs(), listener.getInterpolator(),
                show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE,
                show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE,
                show ? LAYOUT_INSETS_DURING_ANIMATION_SHOWN : LAYOUT_INSETS_DURING_ANIMATION_HIDDEN,
                show ? LAYOUT_INSETS_DURING_ANIMATION_SHOWN : LAYOUT_INSETS_DURING_ANIMATION_HIDDEN,
+35 −12
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.view.InsetsSourceControlProto.POSITION;
import static android.view.InsetsSourceControlProto.TYPE;
import static android.view.InsetsSourceControlProto.TYPE;


import android.annotation.Nullable;
import android.annotation.Nullable;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Point;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
@@ -41,13 +42,19 @@ public class InsetsSourceControl implements Parcelable {
    private final @InternalInsetsType int mType;
    private final @InternalInsetsType int mType;
    private final @Nullable SurfaceControl mLeash;
    private final @Nullable SurfaceControl mLeash;
    private final Point mSurfacePosition;
    private final Point mSurfacePosition;

    // This is used while playing an insets animation regardless of the relative frame. This would
    // be the insets received by the bounds of its source window.
    private Insets mInsetsHint;

    private boolean mSkipAnimationOnce;
    private boolean mSkipAnimationOnce;


    public InsetsSourceControl(@InternalInsetsType int type, @Nullable SurfaceControl leash,
    public InsetsSourceControl(@InternalInsetsType int type, @Nullable SurfaceControl leash,
            Point surfacePosition) {
            Point surfacePosition, Insets insetsHint) {
        mType = type;
        mType = type;
        mLeash = leash;
        mLeash = leash;
        mSurfacePosition = surfacePosition;
        mSurfacePosition = surfacePosition;
        mInsetsHint = insetsHint;
    }
    }


    public InsetsSourceControl(InsetsSourceControl other) {
    public InsetsSourceControl(InsetsSourceControl other) {
@@ -58,9 +65,18 @@ public class InsetsSourceControl implements Parcelable {
            mLeash = null;
            mLeash = null;
        }
        }
        mSurfacePosition = new Point(other.mSurfacePosition);
        mSurfacePosition = new Point(other.mSurfacePosition);
        mInsetsHint = other.mInsetsHint;
        mSkipAnimationOnce = other.getAndClearSkipAnimationOnce();
        mSkipAnimationOnce = other.getAndClearSkipAnimationOnce();
    }
    }


    public InsetsSourceControl(Parcel in) {
        mType = in.readInt();
        mLeash = in.readTypedObject(SurfaceControl.CREATOR);
        mSurfacePosition = in.readTypedObject(Point.CREATOR);
        mInsetsHint = in.readTypedObject(Insets.CREATOR);
        mSkipAnimationOnce = in.readBoolean();
    }

    public int getType() {
    public int getType() {
        return mType;
        return mType;
    }
    }
@@ -75,13 +91,6 @@ public class InsetsSourceControl implements Parcelable {
        return mLeash;
        return mLeash;
    }
    }


    public InsetsSourceControl(Parcel in) {
        mType = in.readInt();
        mLeash = in.readTypedObject(SurfaceControl.CREATOR);
        mSurfacePosition = in.readTypedObject(Point.CREATOR);
        mSkipAnimationOnce = in.readBoolean();
    }

    public boolean setSurfacePosition(int left, int top) {
    public boolean setSurfacePosition(int left, int top) {
        if (mSurfacePosition.equals(left, top)) {
        if (mSurfacePosition.equals(left, top)) {
            return false;
            return false;
@@ -90,14 +99,26 @@ public class InsetsSourceControl implements Parcelable {
        return true;
        return true;
    }
    }


    public void setSkipAnimationOnce(boolean skipAnimation) {
        mSkipAnimationOnce = skipAnimation;
    }

    public Point getSurfacePosition() {
    public Point getSurfacePosition() {
        return mSurfacePosition;
        return mSurfacePosition;
    }
    }


    public void setInsetsHint(Insets insets) {
        mInsetsHint = insets;
    }

    public void setInsetsHint(int left, int top, int right, int bottom) {
        mInsetsHint = Insets.of(left, top, right, bottom);
    }

    public Insets getInsetsHint() {
        return mInsetsHint;
    }

    public void setSkipAnimationOnce(boolean skipAnimation) {
        mSkipAnimationOnce = skipAnimation;
    }

    /**
    /**
     * Get the state whether the current control needs to skip animation or not.
     * Get the state whether the current control needs to skip animation or not.
     *
     *
@@ -121,6 +142,7 @@ public class InsetsSourceControl implements Parcelable {
        dest.writeInt(mType);
        dest.writeInt(mType);
        dest.writeTypedObject(mLeash, 0 /* parcelableFlags */);
        dest.writeTypedObject(mLeash, 0 /* parcelableFlags */);
        dest.writeTypedObject(mSurfacePosition, 0 /* parcelableFlags */);
        dest.writeTypedObject(mSurfacePosition, 0 /* parcelableFlags */);
        dest.writeTypedObject(mInsetsHint, 0 /* parcelableFlags */);
        dest.writeBoolean(mSkipAnimationOnce);
        dest.writeBoolean(mSkipAnimationOnce);
    }
    }


@@ -135,6 +157,7 @@ public class InsetsSourceControl implements Parcelable {
        pw.print("InsetsSourceControl type="); pw.print(InsetsState.typeToString(mType));
        pw.print("InsetsSourceControl type="); pw.print(InsetsState.typeToString(mType));
        pw.print(" mLeash="); pw.print(mLeash);
        pw.print(" mLeash="); pw.print(mLeash);
        pw.print(" mSurfacePosition="); pw.print(mSurfacePosition);
        pw.print(" mSurfacePosition="); pw.print(mSurfacePosition);
        pw.print(" mInsetsHint="); pw.print(mInsetsHint);
        pw.print(" mSkipAnimationOnce="); pw.print(mSkipAnimationOnce);
        pw.print(" mSkipAnimationOnce="); pw.print(mSkipAnimationOnce);
        pw.println();
        pw.println();
    }
    }
Loading