diff --git a/compatLib/build.gradle b/compatLib/build.gradle index 5c3b5a0e13..39e1752ab9 100644 --- a/compatLib/build.gradle +++ b/compatLib/build.gradle @@ -1,5 +1,6 @@ plugins { alias(libs.plugins.android.library) +// alias(libs.plugins.google.protobuf) } android { @@ -13,8 +14,16 @@ android { sourceSets { main { aidl.srcDirs = ['src/main/java'] +// proto { +// srcDirs = ['src/main/java'] +// } } } } -addFrameworkJar('framework-15.jar') +addFrameworkJar('framework-16.jar') +dependencies { + compileOnly files('../prebuilts/libs/framework-16.jar') + compileOnly files('../prebuilts/libs/WindowManager-Shell-16.jar') + compileOnly files('../prebuilts/libs/SystemUI-core-16.jar') +} diff --git a/compatLib/compatLibVQ/src/main/java/app/lawnchair/compatlib/ten/ActivityManagerCompatVQ.java b/compatLib/compatLibVQ/src/main/java/app/lawnchair/compatlib/ten/ActivityManagerCompatVQ.java index 7f799a27b4..b1e4fc5c8a 100644 --- a/compatLib/compatLibVQ/src/main/java/app/lawnchair/compatlib/ten/ActivityManagerCompatVQ.java +++ b/compatLib/compatLibVQ/src/main/java/app/lawnchair/compatlib/ten/ActivityManagerCompatVQ.java @@ -134,7 +134,8 @@ public class ActivityManagerCompatVQ implements ActivityManagerCompat { } } - @Override +// @Override + // pE-TODO(QuickSwitch): Investigate public ThumbnailData takeScreenshot( IRecentsAnimationController animationController, int taskId) { try { diff --git a/compatLib/src/main/java/android/internal/perfetto/protos/insets.proto b/compatLib/src/main/java/android/internal/perfetto/protos/insets.proto new file mode 100644 index 0000000000..4a04c2bcf3 --- /dev/null +++ b/compatLib/src/main/java/android/internal/perfetto/protos/insets.proto @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +option java_package = "android.internal.perfetto.protos"; +option java_outer_classname = "Insets"; + +package perfetto.protos; + +message InsetsProto { + optional int32 left = 1; + optional int32 top = 2; + optional int32 right = 3; + optional int32 bottom = 4; +} diff --git a/compatLib/src/main/java/android/internal/perfetto/protos/insetssource.proto b/compatLib/src/main/java/android/internal/perfetto/protos/insetssource.proto new file mode 100644 index 0000000000..7ef8642625 --- /dev/null +++ b/compatLib/src/main/java/android/internal/perfetto/protos/insetssource.proto @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +option java_package = "android.internal.perfetto.protos"; +option java_outer_classname = "Insetssource"; + +import "main/java/android/internal/perfetto/protos/insets.proto"; +import "main/java/android/internal/perfetto/protos/rect.proto"; + +// Represents a {@link android.view.InsetsSource} object +message InsetsSourceProto { + optional string type = 1 [deprecated = true]; + optional .perfetto.protos.RectProto frame = 2; + optional .perfetto.protos.RectProto visible_frame = 3; + optional bool visible = 4; + optional int32 type_number = 5; + optional .perfetto.protos.InsetsProto attached_insets = 6; +} diff --git a/compatLib/src/main/java/android/internal/perfetto/protos/rect.proto b/compatLib/src/main/java/android/internal/perfetto/protos/rect.proto new file mode 100644 index 0000000000..9f66c04388 --- /dev/null +++ b/compatLib/src/main/java/android/internal/perfetto/protos/rect.proto @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +option java_package = "android.internal.perfetto.protos"; +option java_outer_classname = "Rect"; + +package perfetto.protos; + +message RectProto { + optional int32 left = 1; + optional int32 top = 2; + optional int32 right = 3; + optional int32 bottom = 4; +} diff --git a/compatLib/src/main/java/android/view/ISystemGestureExclusionListener.aidl b/compatLib/src/main/java/android/view/ISystemGestureExclusionListener.aidl index 9c2f9a6a19..729edd91dc 100644 --- a/compatLib/src/main/java/android/view/ISystemGestureExclusionListener.aidl +++ b/compatLib/src/main/java/android/view/ISystemGestureExclusionListener.aidl @@ -38,4 +38,4 @@ oneway interface ISystemGestureExclusionListener { */ void onSystemGestureExclusionChanged(int displayId, in Region systemGestureExclusion, in Region systemGestureExclusionUnrestricted); -} \ No newline at end of file +} diff --git a/compatLib/src/main/java/android/view/InsetsFrameProvider.java b/compatLib/src/main/java/android/view/InsetsFrameProvider.java index 19f016b917..86e9e566b9 100644 --- a/compatLib/src/main/java/android/view/InsetsFrameProvider.java +++ b/compatLib/src/main/java/android/view/InsetsFrameProvider.java @@ -26,50 +26,68 @@ import android.os.Parcel; import android.os.Parcelable; import android.view.InsetsSource.Flags; import android.view.WindowInsets.Type.InsetsType; + import java.util.Arrays; import java.util.Objects; /** * Insets provided by a window. * - *

The insets frame will by default as the window frame size. If the providers are set, the + * The insets frame will by default as the window frame size. If the providers are set, the * calculation result based on the source size will be used as the insets frame. * - *

The InsetsFrameProvider should be self-contained. Nothing describing the window itself, such - * as contentInsets, visibleInsets, etc. won't affect the insets providing to other windows when - * this is set. - * + * The InsetsFrameProvider should be self-contained. Nothing describing the window itself, such as + * contentInsets, visibleInsets, etc. won't affect the insets providing to other windows when this + * is set. * @hide */ public class InsetsFrameProvider implements Parcelable { - /** Uses the display frame as the source. */ + /** + * Uses the display frame as the source. + */ public static final int SOURCE_DISPLAY = 0; - /** Uses the window bounds as the source. */ + /** + * Uses the window bounds as the source. + */ public static final int SOURCE_CONTAINER_BOUNDS = 1; - /** Uses the window frame as the source. */ + /** + * Uses the window frame as the source. + */ public static final int SOURCE_FRAME = 2; - /** Uses {@link #mArbitraryRectangle} as the source. */ + /** + * Uses {@link #mArbitraryRectangle} as the source. + */ public static final int SOURCE_ARBITRARY_RECTANGLE = 3; + /** + * Uses the container bounds to which the insets attached as the source. + * Only use this if the insets is a local insets only applied to the children of the container. + */ + public static final int SOURCE_ATTACHED_CONTAINER_BOUNDS = 4; + private final int mId; - /** The selection of the starting rectangle to be converted into source frame. */ + /** + * The selection of the starting rectangle to be converted into source frame. + */ private int mSource = SOURCE_FRAME; - /** This is used as the source frame only if SOURCE_ARBITRARY_RECTANGLE is applied. */ + /** + * This is used as the source frame only if SOURCE_ARBITRARY_RECTANGLE is applied. + */ private Rect mArbitraryRectangle; /** * Modifies the starting rectangle selected by {@link #mSource}. * - *

For example, when the given source frame is (0, 0) - (100, 200), and the insetsSize is - * null, the source frame will be directly used as the final insets frame. If the insetsSize is - * set to (0, 0, 0, 50) instead, the insets frame will be a frame starting from the bottom side - * of the source frame with height of 50, i.e., (0, 150) - (100, 200). + * For example, when the given source frame is (0, 0) - (100, 200), and the insetsSize is null, + * the source frame will be directly used as the final insets frame. If the insetsSize is set to + * (0, 0, 0, 50) instead, the insets frame will be a frame starting from the bottom side of the + * source frame with height of 50, i.e., (0, 150) - (100, 200). */ private Insets mInsetsSize = null; @@ -94,8 +112,7 @@ public class InsetsFrameProvider implements Parcelable { * the layout of the window, but only change the insets frame. This can be applied to insets * calculated based on all three source frames. * - *

Be cautious, this will not be in effect for the window types whose insets size is - * overridden. + * Be cautious, this will not be in effect for the window types whose insets size is overridden. */ private Insets mMinimalInsetsSizeInDisplayCutoutSafe = null; @@ -109,23 +126,28 @@ public class InsetsFrameProvider implements Parcelable { * Creates an InsetsFrameProvider which describes what frame an insets source should have. * * @param owner the owner of this provider. We might have multiple sources with the same type on - * a display, this is used to identify them. + * a display, this is used to identify them. * @param index the index of this provider. An owner might provide multiple sources with the - * same type, this is used to identify them. The value must be in a range of [0, 2047]. + * same type, this is used to identify them. + * The value must be in a range of [0, 2047]. * @param type the {@link InsetsType}. * @see InsetsSource#createId(Object, int, int) */ - public InsetsFrameProvider( - Object owner, @IntRange(from = 0, to = 2047) int index, @InsetsType int type) { + public InsetsFrameProvider(Object owner, @IntRange(from = 0, to = 2047) int index, + @InsetsType int type) { mId = InsetsSource.createId(owner, index, type); } - /** Returns an unique integer which identifies the insets source. */ + /** + * Returns an unique integer which identifies the insets source. + */ public int getId() { return mId; } - /** Returns the index specified in {@link #InsetsFrameProvider(IBinder, int, int)}. */ + /** + * Returns the index specified in {@link #InsetsFrameProvider(IBinder, int, int)}. + */ public int getIndex() { return InsetsSource.getIndex(mId); } @@ -146,6 +168,12 @@ public class InsetsFrameProvider implements Parcelable { return mSource; } + /** Set the flags of this provider. */ + public InsetsFrameProvider setFlags(@Flags int flags) { + mFlags = flags; + return this; + } + public InsetsFrameProvider setFlags(@Flags int flags, @Flags int mask) { mFlags = (mFlags & ~mask) | (flags & mask); return this; @@ -196,13 +224,17 @@ public class InsetsFrameProvider implements Parcelable { return mMinimalInsetsSizeInDisplayCutoutSafe; } - /** Sets the bounding rectangles within and relative to the source frame. */ + /** + * Sets the bounding rectangles within and relative to the source frame. + */ public InsetsFrameProvider setBoundingRects(@Nullable Rect[] boundingRects) { mBoundingRects = boundingRects == null ? null : boundingRects.clone(); return this; } - /** Returns the arbitrary bounding rects, or null if none were set. */ + /** + * Returns the arbitrary bounding rects, or null if none were set. + */ @Nullable public Rect[] getBoundingRects() { return mBoundingRects; @@ -251,6 +283,8 @@ public class InsetsFrameProvider implements Parcelable { return "FRAME"; case SOURCE_ARBITRARY_RECTANGLE: return "ARBITRARY_RECTANGLE"; + case SOURCE_ATTACHED_CONTAINER_BOUNDS: + return "ATTACHED_CONTAINER_BOUNDS"; } return "UNDEFINED"; } @@ -291,29 +325,20 @@ public class InsetsFrameProvider implements Parcelable { return false; } final InsetsFrameProvider other = (InsetsFrameProvider) o; - return mId == other.mId - && mSource == other.mSource - && mFlags == other.mFlags + return mId == other.mId && mSource == other.mSource && mFlags == other.mFlags && Objects.equals(mInsetsSize, other.mInsetsSize) && Arrays.equals(mInsetsSizeOverrides, other.mInsetsSizeOverrides) && Objects.equals(mArbitraryRectangle, other.mArbitraryRectangle) - && Objects.equals( - mMinimalInsetsSizeInDisplayCutoutSafe, + && Objects.equals(mMinimalInsetsSizeInDisplayCutoutSafe, other.mMinimalInsetsSizeInDisplayCutoutSafe) && Arrays.equals(mBoundingRects, other.mBoundingRects); } @Override public int hashCode() { - return Objects.hash( - mId, - mSource, - mFlags, - mInsetsSize, - Arrays.hashCode(mInsetsSizeOverrides), - mArbitraryRectangle, - mMinimalInsetsSizeInDisplayCutoutSafe, - Arrays.hashCode(mBoundingRects)); + return Objects.hash(mId, mSource, mFlags, mInsetsSize, + Arrays.hashCode(mInsetsSizeOverrides), mArbitraryRectangle, + mMinimalInsetsSizeInDisplayCutoutSafe, Arrays.hashCode(mBoundingRects)); } public static final @NonNull Parcelable.Creator CREATOR = @@ -333,8 +358,8 @@ public class InsetsFrameProvider implements Parcelable { * Class to describe the insets size to be provided to window with specific window type. If not * used, same insets size will be sent as instructed in the insetsSize and source. * - *

If the insetsSize of given type is set to {@code null}, the insets source frame will be - * used directly for that window type. + * If the insetsSize of given type is set to {@code null}, the insets source frame will be used + * directly for that window type. */ public static class InsetsSizeOverride implements Parcelable { @@ -350,7 +375,6 @@ public class InsetsFrameProvider implements Parcelable { mWindowType = windowType; mInsetsSize = insetsSize; } - public int getWindowType() { return mWindowType; } @@ -359,18 +383,17 @@ public class InsetsFrameProvider implements Parcelable { return mInsetsSize; } - public static final Creator CREATOR = - new Creator<>() { - @Override - public InsetsSizeOverride createFromParcel(Parcel in) { - return new InsetsSizeOverride(in); - } + public static final Creator CREATOR = new Creator<>() { + @Override + public InsetsSizeOverride createFromParcel(Parcel in) { + return new InsetsSizeOverride(in); + } - @Override - public InsetsSizeOverride[] newArray(int size) { - return new InsetsSizeOverride[size]; - } - }; + @Override + public InsetsSizeOverride[] newArray(int size) { + return new InsetsSizeOverride[size]; + } + }; @Override public int describeContents() { @@ -387,10 +410,8 @@ public class InsetsFrameProvider implements Parcelable { public String toString() { StringBuilder sb = new StringBuilder(32); sb.append("TypedInsetsSize: {"); - sb.append("windowType=") - .append( - ViewDebug.intToString( - WindowManager.LayoutParams.class, "type", mWindowType)); + sb.append("windowType=").append(ViewDebug.intToString( + WindowManager.LayoutParams.class, "type", mWindowType)); sb.append(", insetsSize=").append(mInsetsSize); sb.append("}"); return sb.toString(); diff --git a/compatLib/src/main/java/android/view/InsetsSource.java b/compatLib/src/main/java/android/view/InsetsSource.java index 71f0516408..f16a5194ef 100644 --- a/compatLib/src/main/java/android/view/InsetsSource.java +++ b/compatLib/src/main/java/android/view/InsetsSource.java @@ -16,6 +16,7 @@ package android.view; +import static android.view.InsetsSourceProto.ATTACHED_INSETS; import static android.view.InsetsSourceProto.FRAME; import static android.view.InsetsSourceProto.TYPE; import static android.view.InsetsSourceProto.TYPE_NUMBER; @@ -34,6 +35,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.proto.ProtoOutputStream; import android.view.WindowInsets.Type.InsetsType; + import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -44,15 +46,19 @@ import java.util.StringJoiner; /** * Represents the state of a single entity generating insets for clients. - * * @hide */ public class InsetsSource implements Parcelable { @Retention(RetentionPolicy.SOURCE) - @IntDef( - prefix = "SIDE_", - value = {SIDE_NONE, SIDE_LEFT, SIDE_TOP, SIDE_RIGHT, SIDE_BOTTOM, SIDE_UNKNOWN}) + @IntDef(prefix = "SIDE_", value = { + SIDE_NONE, + SIDE_LEFT, + SIDE_TOP, + SIDE_RIGHT, + SIDE_BOTTOM, + SIDE_UNKNOWN + }) public @interface InternalInsetsSide {} static final int SIDE_NONE = 0; @@ -83,28 +89,46 @@ public class InsetsSource implements Parcelable { * Controls whether the insets frame will be used to move {@link RoundedCorner} inward with the * insets frame size when calculating the rounded corner insets to other windows. * - *

For example, task bar will draw fake rounded corners above itself, so we need to move the + * For example, task bar will draw fake rounded corners above itself, so we need to move the * rounded corner up by the task bar insets size to make other windows see a rounded corner * above the task bar. */ public static final int FLAG_INSETS_ROUNDED_CORNER = 1 << 1; - /** Controls whether the insets provided by this source should be forcibly consumed. */ + /** + * Controls whether the insets provided by this source should be forcibly consumed. + */ public static final int FLAG_FORCE_CONSUMING = 1 << 2; - /** Controls whether the insets source will play an animation when resizing. */ + /** + * Controls whether the insets source will play an animation when resizing. + */ public static final int FLAG_ANIMATE_RESIZING = 1 << 3; + /** + * Controls whether the {@link WindowInsets.Type#captionBar()} insets provided by this source + * should always be forcibly consumed. Unlike with {@link #FLAG_FORCE_CONSUMING}, when this + * flag is used the caption bar will be consumed even when the bar is requested to be visible. + * + * Note: this flag does not take effect when the window applies + * {@link WindowInsetsController.Appearance#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND}. + */ + public static final int FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR = 1 << 4; + + /** + * Indicates whether the insets source is valid. + */ + public static final int FLAG_INVALID = 1 << 5; + @Retention(RetentionPolicy.SOURCE) - @IntDef( - flag = true, - prefix = "FLAG_", - value = { - FLAG_SUPPRESS_SCRIM, - FLAG_INSETS_ROUNDED_CORNER, - FLAG_FORCE_CONSUMING, - FLAG_ANIMATE_RESIZING, - }) + @IntDef(flag = true, prefix = "FLAG_", value = { + FLAG_SUPPRESS_SCRIM, + FLAG_INSETS_ROUNDED_CORNER, + FLAG_FORCE_CONSUMING, + FLAG_ANIMATE_RESIZING, + FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR, + FLAG_INVALID, + }) public @interface Flags {} /** @@ -115,17 +139,22 @@ public class InsetsSource implements Parcelable { private @Flags int mFlags; - /** An unique integer to identify this source across processes. */ + /** + * An unique integer to identify this source across processes. + */ private final int mId; private final @InsetsType int mType; /** Frame of the source in screen coordinate space */ private final Rect mFrame; - private @Nullable Rect mVisibleFrame; private @Nullable Rect[] mBoundingRects; + // If not null, this will be used to calculate insets based on the container bounds the insets + // source attached to, and all other frame, including side hints will be ignored. + private @Nullable Insets mAttachedInsets; + private boolean mVisible; /** @@ -135,7 +164,7 @@ public class InsetsSource implements Parcelable { private @InternalInsetsSide int mSideHint = SIDE_NONE; private final Rect mTmpFrame = new Rect(); - private final Rect mTmpBoundingRect = new Rect(); + private final Rect mTmpFrame2 = new Rect(); public InsetsSource(int id, @InsetsType int type) { mId = id; @@ -149,19 +178,29 @@ public class InsetsSource implements Parcelable { mType = other.mType; mFrame = new Rect(other.mFrame); mVisible = other.mVisible; - mVisibleFrame = other.mVisibleFrame != null ? new Rect(other.mVisibleFrame) : null; + mVisibleFrame = other.mVisibleFrame != null + ? new Rect(other.mVisibleFrame) + : null; mFlags = other.mFlags; mSideHint = other.mSideHint; - mBoundingRects = other.mBoundingRects != null ? other.mBoundingRects.clone() : null; + mBoundingRects = other.mBoundingRects != null + ? other.mBoundingRects.clone() + : null; + mAttachedInsets = other.mAttachedInsets; } public void set(InsetsSource other) { mFrame.set(other.mFrame); mVisible = other.mVisible; - mVisibleFrame = other.mVisibleFrame != null ? new Rect(other.mVisibleFrame) : null; + mVisibleFrame = other.mVisibleFrame != null + ? new Rect(other.mVisibleFrame) + : null; mFlags = other.mFlags; mSideHint = other.mSideHint; - mBoundingRects = other.mBoundingRects != null ? other.mBoundingRects.clone() : null; + mBoundingRects = other.mBoundingRects != null + ? other.mBoundingRects.clone() + : null; + mAttachedInsets = other.mAttachedInsets; } public InsetsSource setFrame(int left, int top, int right, int bottom) { @@ -179,6 +218,11 @@ public class InsetsSource implements Parcelable { return this; } + public InsetsSource setAttachedInsets(@Nullable Insets attachedInsets) { + mAttachedInsets = attachedInsets; + return this; + } + public InsetsSource setVisible(boolean visible) { mVisible = visible; return this; @@ -201,7 +245,9 @@ public class InsetsSource implements Parcelable { * @param bounds A rectangle which contains the frame. It will be used to calculate the hint. */ public InsetsSource updateSideHint(Rect bounds) { - mSideHint = getInsetSide(calculateInsets(bounds, mFrame, true /* ignoreVisibility */)); + mSideHint = getInsetSide(mAttachedInsets != null + ? mAttachedInsets + : calculateArbitraryInsets(bounds, mFrame, true /* ignoreVisibility */)); return this; } @@ -242,35 +288,67 @@ public class InsetsSource implements Parcelable { return (mFlags & flags) == flags; } - /** Returns the bounding rectangles of this source. */ + /** + * Returns the bounding rectangles of this source. + */ public @Nullable Rect[] getBoundingRects() { return mBoundingRects; } + public @Nullable Insets getAttachedInsets() { + return mAttachedInsets; + } + /** * Calculates the insets this source will cause to a client window. * * @param relativeFrame The frame to calculate the insets relative to. + * @param hostBounds the bounds of the host window. Can be none if no local insets with + * attached insets is set. * @param ignoreVisibility If true, always reports back insets even if source isn't visible. * @return The resulting insets. The contract is that only one side will be occupied by a - * source. + * source. */ - public Insets calculateInsets(Rect relativeFrame, boolean ignoreVisibility) { - return calculateInsets(relativeFrame, mFrame, ignoreVisibility); + public Insets calculateInsets(Rect relativeFrame, @Nullable Rect hostBounds, + boolean ignoreVisibility) { + if (mAttachedInsets != null) { + return calculateAttachedInsets(relativeFrame, hostBounds, ignoreVisibility); + } else { + return calculateArbitraryInsets(relativeFrame, mFrame, ignoreVisibility); + } } - /** Like {@link #calculateInsets(Rect, boolean)}, but will return visible insets. */ - public Insets calculateVisibleInsets(Rect relativeFrame) { - return calculateInsets( - relativeFrame, - mVisibleFrame != null ? mVisibleFrame : mFrame, - false /* ignoreVisibility */); + /** + * Like {@link #calculateInsets(Rect, Rect, boolean)}, but will return visible insets. + */ + public Insets calculateVisibleInsets(Rect relativeFrame, Rect hostBounds) { + if (mAttachedInsets != null) { + return calculateAttachedInsets(relativeFrame, hostBounds, + false /* ignoreVisibility */); + } else { + return calculateArbitraryInsets(relativeFrame, mVisibleFrame != null + ? mVisibleFrame : mFrame, false /* ignoreVisibility */); + } } - private Insets calculateInsets(Rect relativeFrame, Rect frame, boolean ignoreVisibility) { + /** + * Calculates the insets this source will cause to a client window. The insets frame is a given + * rectangle on a display coordinate system, and the client window frame is also on the same + * coordinate system. + * + * @param relativeFrame The frame to calculate the insets relative to. The client window + * frame. + * @param frame the frame of the insets to be used during the calculation. + * @param ignoreVisibility If true, always reports back insets even if source isn't visible. + * @return The resulting insets. The contract is that only one side will be occupied by a + * source. + */ + private Insets calculateArbitraryInsets(Rect relativeFrame, Rect frame, + boolean ignoreVisibility) { if (!ignoreVisibility && !mVisible) { return Insets.NONE; } + // During drag-move and drag-resizing, the caption insets position may not get updated // before the app frame get updated. To layout the app content correctly during drag events, // we always return the insets with the corresponding height covering the top. @@ -282,10 +360,9 @@ public class InsetsSource implements Parcelable { : Insets.of(0, frame.height(), 0, 0); } // Checks for whether there is shared edge with insets for 0-width/height window. - final boolean hasIntersection = - relativeFrame.isEmpty() - ? getIntersection(frame, relativeFrame, mTmpFrame) - : mTmpFrame.setIntersect(frame, relativeFrame); + final boolean hasIntersection = relativeFrame.isEmpty() + ? getIntersection(frame, relativeFrame, mTmpFrame) + : mTmpFrame.setIntersect(frame, relativeFrame); if (!hasIntersection) { return Insets.NONE; } @@ -329,11 +406,71 @@ public class InsetsSource implements Parcelable { } else if (mTmpFrame.right == relativeFrame.right) { return Insets.of(0, 0, mTmpFrame.width(), 0); } + } else { + // The source doesn't cover the width or the height of relativeFrame, but just parts of + // them. Here uses mSideHint to decide which side should be inset. + switch (mSideHint) { + case SIDE_LEFT: + if (mTmpFrame.left == relativeFrame.left) { + return Insets.of(mTmpFrame.width(), 0, 0, 0); + } + break; + case SIDE_TOP: + if (mTmpFrame.top == relativeFrame.top) { + return Insets.of(0, mTmpFrame.height(), 0, 0); + } + break; + case SIDE_RIGHT: + if (mTmpFrame.right == relativeFrame.right) { + return Insets.of(0, 0, mTmpFrame.width(), 0); + } + break; + case SIDE_BOTTOM: + if (mTmpFrame.bottom == relativeFrame.bottom) { + return Insets.of(0, 0, 0, mTmpFrame.height()); + } + break; + } } return Insets.NONE; } - /** Calculates the bounding rects the source will cause to a client window. */ + /** + * Calculates the insets this source will cause to a client window when the insets is attached + * to a container. + * + * @param relativeFrame The frame to calculate the insets relative to. + * @param hostBounds the bounds of the container where the insets attached to. + * @param ignoreVisibility If true, always reports back insets even if source isn't visible. + * @return The resulting insets. The contract is that only one side will be occupied by a + * source. + */ + private Insets calculateAttachedInsets(Rect relativeFrame, Rect hostBounds, + boolean ignoreVisibility) { + if (hostBounds == null) { + throw new IllegalArgumentException("A local relative insets requires the host " + + "container bounds to be calculated correctly."); + } + if (!ignoreVisibility && !mVisible) { + return Insets.NONE; + } + if (!mAttachedInsets.equals(Insets.NONE)) { + mTmpFrame2.set(hostBounds); + mTmpFrame2.inset(mAttachedInsets); + return mTmpFrame.setIntersect(mTmpFrame2, relativeFrame) + ? Insets.of( + mTmpFrame.left - relativeFrame.left, + mTmpFrame.top - relativeFrame.top, + relativeFrame.right - mTmpFrame.right, + relativeFrame.bottom - mTmpFrame.bottom) + : Insets.NONE; + } + return Insets.NONE; + } + + /** + * Calculates the bounding rects the source will cause to a client window. + */ public @NonNull Rect[] calculateBoundingRects(Rect relativeFrame, boolean ignoreVisibility) { if (!ignoreVisibility && !mVisible) { return NO_BOUNDING_RECTS; @@ -343,13 +480,14 @@ public class InsetsSource implements Parcelable { if (mBoundingRects == null) { // No bounding rects set, make a single bounding rect that covers the intersection of // the |frame| and the |relativeFrame|. Also make it relative to the window origin. - return mTmpBoundingRect.setIntersect(frame, relativeFrame) - ? new Rect[] { - new Rect( - mTmpBoundingRect.left - relativeFrame.left, - mTmpBoundingRect.top - relativeFrame.top, - mTmpBoundingRect.right - relativeFrame.left, - mTmpBoundingRect.bottom - relativeFrame.top) + return mTmpFrame2.setIntersect(frame, relativeFrame) + ? new Rect[]{ + new Rect( + mTmpFrame2.left - relativeFrame.left, + mTmpFrame2.top - relativeFrame.top, + mTmpFrame2.right - relativeFrame.left, + mTmpFrame2.bottom - relativeFrame.top + ) } : NO_BOUNDING_RECTS; } @@ -368,11 +506,11 @@ public class InsetsSource implements Parcelable { // |frame| either is already relative to |relativeFrame| (for top captionBar()), or // just needs to be made relative to |relativeFrame| for bottom bars. final int frameHeight = frame.height(); - mTmpBoundingRect.set(boundingRect); + mTmpFrame2.set(boundingRect); if (getId() == ID_IME_CAPTION_BAR) { - mTmpBoundingRect.offset(0, relativeFrame.height() - frameHeight); + mTmpFrame2.offset(0, relativeFrame.height() - frameHeight); } - validBoundingRects.add(new Rect(mTmpBoundingRect)); + validBoundingRects.add(new Rect(mTmpFrame2)); } return validBoundingRects.toArray(new Rect[validBoundingRects.size()]); } @@ -382,15 +520,15 @@ public class InsetsSource implements Parcelable { for (final Rect boundingRect : mBoundingRects) { // |boundingRect| was provided relative to |frame|. Make it absolute to be in the same // coordinate system as |frame|. - final Rect absBoundingRect = - new Rect( - boundingRect.left + frame.left, - boundingRect.top + frame.top, - boundingRect.right + frame.left, - boundingRect.bottom + frame.top); + final Rect absBoundingRect = new Rect( + boundingRect.left + frame.left, + boundingRect.top + frame.top, + boundingRect.right + frame.left, + boundingRect.bottom + frame.top + ); // Now find the intersection of that |absBoundingRect| with |relativeFrame|. In other // words, whichever part of the bounding rect is inside the window frame. - if (!mTmpBoundingRect.setIntersect(absBoundingRect, relativeFrame)) { + if (!mTmpFrame2.setIntersect(absBoundingRect, relativeFrame)) { // It's possible for this to be empty if the frame and bounding rects were larger // than the |relativeFrame|, such as when a system window is wider than the app // window width. Just ignore that rect since it will have no effect on the @@ -400,12 +538,11 @@ public class InsetsSource implements Parcelable { // At this point, |mTmpBoundingRect| is a valid bounding rect located fully inside the // window, convert it to be relative to the window so that apps don't need to know the // location of the window to understand bounding rects. - validBoundingRects.add( - new Rect( - mTmpBoundingRect.left - relativeFrame.left, - mTmpBoundingRect.top - relativeFrame.top, - mTmpBoundingRect.right - relativeFrame.left, - mTmpBoundingRect.bottom - relativeFrame.top)); + validBoundingRects.add(new Rect( + mTmpFrame2.left - relativeFrame.left, + mTmpFrame2.top - relativeFrame.top, + mTmpFrame2.right - relativeFrame.left, + mTmpFrame2.bottom - relativeFrame.top)); } if (validBoundingRects.isEmpty()) { return NO_BOUNDING_RECTS; @@ -479,13 +616,13 @@ public class InsetsSource implements Parcelable { * * @param owner An object owned by the owner. Only the owner can modify its own sources. * @param index An owner may have multiple sources with the same type. For example, the system - * server might have multiple display cutout sources. This is used to identify which one is - * which. The value must be in a range of [0, 2047]. + * server might have multiple display cutout sources. This is used to identify + * which one is which. The value must be in a range of [0, 2047]. * @param type The {@link InsetsType type} of the source. * @return a unique integer as the identifier. */ - public static int createId( - Object owner, @IntRange(from = 0, to = 2047) int index, @InsetsType int type) { + public static int createId(Object owner, @IntRange(from = 0, to = 2047) int index, + @InsetsType int type) { if (index < 0 || index >= 2048) { throw new IllegalArgumentException(); } @@ -536,13 +673,19 @@ public class InsetsSource implements Parcelable { if ((flags & FLAG_ANIMATE_RESIZING) != 0) { joiner.add("ANIMATE_RESIZING"); } + if ((flags & FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR) != 0) { + joiner.add("FORCE_CONSUMING_OPAQUE_CAPTION_BAR"); + } + if ((flags & FLAG_INVALID) != 0) { + joiner.add("INVALID"); + } return joiner.toString(); } /** * Export the state of {@link InsetsSource} into a protocol buffer output stream. * - * @param proto Stream to write the state to + * @param proto Stream to write the state to * @param fieldId FieldId of InsetsSource as defined in the parent message */ public void dumpDebug(ProtoOutputStream proto, long fieldId) { @@ -557,29 +700,28 @@ public class InsetsSource implements Parcelable { } proto.write(VISIBLE, mVisible); proto.write(TYPE_NUMBER, mType); + if (mAttachedInsets != null) { + mAttachedInsets.dumpDebug(proto, ATTACHED_INSETS); + } proto.end(token); } public void dump(String prefix, PrintWriter pw) { pw.print(prefix); - pw.print("InsetsSource id="); - pw.print(Integer.toHexString(mId)); - pw.print(" type="); - pw.print(WindowInsets.Type.toString(mType)); - pw.print(" frame="); - pw.print(mFrame.toShortString()); - if (mVisibleFrame != null) { - pw.print(" visibleFrame="); - pw.print(mVisibleFrame.toShortString()); + pw.print("InsetsSource id="); pw.print(Integer.toHexString(mId)); + pw.print(" type="); pw.print(WindowInsets.Type.toString(mType)); + if (mAttachedInsets != null) { + pw.print(" attachedInsets="); pw.print(mAttachedInsets); + } else { + pw.print(" frame="); pw.print(mFrame.toShortString()); } - pw.print(" visible="); - pw.print(mVisible); - pw.print(" flags="); - pw.print(flagsToString(mFlags)); - pw.print(" sideHint="); - pw.print(sideToString(mSideHint)); - pw.print(" boundingRects="); - pw.print(Arrays.toString(mBoundingRects)); + if (mVisibleFrame != null) { + pw.print(" visibleFrame="); pw.print(mVisibleFrame.toShortString()); + } + pw.print(" visible="); pw.print(mVisible); + pw.print(" flags="); pw.print(flagsToString(mFlags)); + pw.print(" sideHint="); pw.print(sideToString(mSideHint)); + pw.print(" boundingRects="); pw.print(Arrays.toString(mBoundingRects)); pw.println(); } @@ -590,7 +732,7 @@ public class InsetsSource implements Parcelable { /** * @param excludeInvisibleImeFrames If {@link WindowInsets.Type#ime()} frames should be ignored - * when IME is not visible. + * when IME is not visible. */ public boolean equals(@Nullable Object o, boolean excludeInvisibleImeFrames) { if (this == o) return true; @@ -611,14 +753,7 @@ public class InsetsSource implements Parcelable { @Override public int hashCode() { - return Objects.hash( - mId, - mType, - mFrame, - mVisibleFrame, - mVisible, - mFlags, - mSideHint, + return Objects.hash(mId, mType, mFrame, mVisibleFrame, mVisible, mFlags, mSideHint, Arrays.hashCode(mBoundingRects)); } @@ -635,6 +770,11 @@ public class InsetsSource implements Parcelable { mFlags = in.readInt(); mSideHint = in.readInt(); mBoundingRects = in.createTypedArray(Rect.CREATOR); + if (in.readInt() != 0) { + mAttachedInsets = Insets.CREATOR.createFromParcel(in); + } else { + mAttachedInsets = null; + } } @Override @@ -657,36 +797,35 @@ public class InsetsSource implements Parcelable { dest.writeInt(mFlags); dest.writeInt(mSideHint); dest.writeTypedArray(mBoundingRects, flags); + if (mAttachedInsets != null) { + dest.writeInt(1); + mAttachedInsets.writeToParcel(dest, flags); + } else { + dest.writeInt(0); + } } @Override public String toString() { - return "InsetsSource: {" - + Integer.toHexString(mId) - + " mType=" - + WindowInsets.Type.toString(mType) - + " mFrame=" - + mFrame.toShortString() - + " mVisible=" - + mVisible - + " mFlags=" - + flagsToString(mFlags) - + " mSideHint=" - + sideToString(mSideHint) - + " mBoundingRects=" - + Arrays.toString(mBoundingRects) + return "InsetsSource: {" + Integer.toHexString(mId) + + " mType=" + WindowInsets.Type.toString(mType) + + " mFrame=" + mFrame.toShortString() + + " mAttachedInsets=" + mAttachedInsets + + " mVisible=" + mVisible + + " mFlags=" + flagsToString(mFlags) + + " mSideHint=" + sideToString(mSideHint) + + " mBoundingRects=" + Arrays.toString(mBoundingRects) + "}"; } - public static final @NonNull Creator CREATOR = - new Creator<>() { + public static final @NonNull Creator CREATOR = new Creator<>() { - public InsetsSource createFromParcel(Parcel in) { - return new InsetsSource(in); - } + public InsetsSource createFromParcel(Parcel in) { + return new InsetsSource(in); + } - public InsetsSource[] newArray(int size) { - return new InsetsSource[size]; - } - }; + public InsetsSource[] newArray(int size) { + return new InsetsSource[size]; + } + }; } diff --git a/compatLib/src/main/java/android/window/IRemoteTransition.aidl b/compatLib/src/main/java/android/window/IRemoteTransition.aidl index c66910f2b6..33421ba519 100644 --- a/compatLib/src/main/java/android/window/IRemoteTransition.aidl +++ b/compatLib/src/main/java/android/window/IRemoteTransition.aidl @@ -81,4 +81,4 @@ oneway interface IRemoteTransition { * @param aborted Whether the transition is aborted or not. */ void onTransitionConsumed(in IBinder transition, in boolean aborted); -} \ No newline at end of file +} diff --git a/compatLib/src/main/java/android/window/IRemoteTransitionFinishedCallback.aidl b/compatLib/src/main/java/android/window/IRemoteTransitionFinishedCallback.aidl index e11ebe3156..7864c24531 100644 --- a/compatLib/src/main/java/android/window/IRemoteTransitionFinishedCallback.aidl +++ b/compatLib/src/main/java/android/window/IRemoteTransitionFinishedCallback.aidl @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License */ + package android.window; + import android.view.SurfaceControl; import android.window.WindowContainerTransaction; + /** * Interface to be invoked by the controlling process when a remote transition has finished. * @@ -27,4 +30,4 @@ import android.window.WindowContainerTransaction; */ interface IRemoteTransitionFinishedCallback { void onTransitionFinished(in WindowContainerTransaction wct, in SurfaceControl.Transaction sct); -} \ No newline at end of file +} diff --git a/compatLib/src/main/java/android/window/OnBackAnimationCallback.java b/compatLib/src/main/java/android/window/OnBackAnimationCallback.java index b2e5624baa..9119e71cc6 100644 --- a/compatLib/src/main/java/android/window/OnBackAnimationCallback.java +++ b/compatLib/src/main/java/android/window/OnBackAnimationCallback.java @@ -14,7 +14,6 @@ * limitations under the License. */ package android.window; - import android.annotation.NonNull; import android.app.Activity; import android.app.Dialog; @@ -22,30 +21,29 @@ import android.view.View; import android.view.Window; /** - * Interface for applications to register back animation callbacks along their custom back handling. - * - *

This allows the client to customize various back behaviors by overriding the corresponding + * Interface for applications to register back animation callbacks along their custom back + * handling. + *

+ * This allows the client to customize various back behaviors by overriding the corresponding * callback methods. - * - *

Callback instances can be added to and removed from {@link OnBackInvokedDispatcher}, which is - * held at window level and accessible through {@link Activity#getOnBackInvokedDispatcher()}, {@link - * Dialog#getOnBackInvokedDispatcher()}, {@link Window#getOnBackInvokedDispatcher()} and {@link - * View#findOnBackInvokedDispatcher()}. - * - *

When back is triggered, callbacks on the in-focus window are invoked in reverse order in which + *

+ * Callback instances can be added to and removed from {@link OnBackInvokedDispatcher}, which + * is held at window level and accessible through {@link Activity#getOnBackInvokedDispatcher()}, + * {@link Dialog#getOnBackInvokedDispatcher()}, {@link Window#getOnBackInvokedDispatcher()} + * and {@link View#findOnBackInvokedDispatcher()}. + *

+ * When back is triggered, callbacks on the in-focus window are invoked in reverse order in which * they are added within the same priority. Between different priorities, callbacks with higher * priority are invoked first. - * *

- * * @see OnBackInvokedCallback */ public interface OnBackAnimationCallback extends OnBackInvokedCallback { /** * Called when a back gesture has been started, or back button has been pressed down. * - * @param backEvent The {@link BackEvent} containing information about the touch or button - * press. + * @param backEvent The {@link BackEvent} containing information about the touch or + * button press. * @see BackEvent */ default void onBackStarted(@NonNull BackEvent backEvent) {} @@ -54,10 +52,12 @@ public interface OnBackAnimationCallback extends OnBackInvokedCallback { * Called when a back gesture progresses. * * @param backEvent An {@link BackEvent} object describing the progress event. + * * @see BackEvent */ - default void onBackProgressed(@NonNull BackEvent backEvent) {} - - /** Called when a back gesture or back button press has been cancelled. */ - default void onBackCancelled() {} + default void onBackProgressed(@NonNull BackEvent backEvent) { } + /** + * Called when a back gesture or back button press has been cancelled. + */ + default void onBackCancelled() { } } diff --git a/compatLib/src/main/java/android/window/OnBackInvokedCallback.java b/compatLib/src/main/java/android/window/OnBackInvokedCallback.java index ab6b08971e..6beaad339b 100644 --- a/compatLib/src/main/java/android/window/OnBackInvokedCallback.java +++ b/compatLib/src/main/java/android/window/OnBackInvokedCallback.java @@ -23,32 +23,31 @@ import android.view.Window; /** * Callback allowing applications to handle back events in place of the system. - * - *

Callback instances can be added to and removed from {@link OnBackInvokedDispatcher}, which is - * held at window level and accessible through {@link Activity#getOnBackInvokedDispatcher()}, {@link - * Dialog#getOnBackInvokedDispatcher()}, {@link Window#getOnBackInvokedDispatcher()} and {@link - * View#findOnBackInvokedDispatcher()}. - * - *

When back is triggered, callbacks on the in-focus window are invoked in reverse order in which + *

+ * Callback instances can be added to and removed from {@link OnBackInvokedDispatcher}, which + * is held at window level and accessible through {@link Activity#getOnBackInvokedDispatcher()}, + * {@link Dialog#getOnBackInvokedDispatcher()}, {@link Window#getOnBackInvokedDispatcher()} + * and {@link View#findOnBackInvokedDispatcher()}. + *

+ * When back is triggered, callbacks on the in-focus window are invoked in reverse order in which * they are added within the same priority. Between different priorities, callbacks with higher * priority are invoked first. - * - *

This replaces {@link Activity#onBackPressed()}, {@link Dialog#onBackPressed()} and {@link - * android.view.KeyEvent#KEYCODE_BACK} - * - *

If you want to customize back animation behaviors, in addition to handling back invocations, - * register its subclass instances {@link OnBackAnimationCallback} instead. - * *

- * + * This replaces {@link Activity#onBackPressed()}, {@link Dialog#onBackPressed()} and + * {@link android.view.KeyEvent#KEYCODE_BACK} + *

+ * If you want to customize back animation behaviors, in addition to handling back invocations, + * register its subclass instances {@link OnBackAnimationCallback} instead. + *

* @see OnBackInvokedDispatcher#registerOnBackInvokedCallback(int, OnBackInvokedCallback) - * registerOnBackInvokedCallback(priority, OnBackInvokedCallback) to specify callback priority. + * registerOnBackInvokedCallback(priority, OnBackInvokedCallback) + * to specify callback priority. */ @SuppressWarnings("deprecation") public interface OnBackInvokedCallback { /** - * Called when a back gesture has been completed and committed, or back button pressed has been - * released and committed. + * Called when a back gesture has been completed and committed, or back button pressed + * has been released and committed. */ void onBackInvoked(); } diff --git a/compatLib/src/main/java/android/window/RemoteTransition.java b/compatLib/src/main/java/android/window/RemoteTransition.java index e7635b5cb2..15b3c4490f 100644 --- a/compatLib/src/main/java/android/window/RemoteTransition.java +++ b/compatLib/src/main/java/android/window/RemoteTransition.java @@ -25,7 +25,6 @@ import android.os.Parcelable; /** * Represents a remote transition animation and information required to run it (eg. the app thread * that needs to be boosted). - * * @hide */ public final class RemoteTransition implements Parcelable { @@ -41,7 +40,6 @@ public final class RemoteTransition implements Parcelable { /** * Constructs with no app thread (animation runs in shell). - * * @hide */ public RemoteTransition(@NonNull IRemoteTransition remoteTransition) { @@ -50,11 +48,10 @@ public final class RemoteTransition implements Parcelable { /** * Constructs with no app thread (animation runs in shell). - * * @hide */ - public RemoteTransition( - @NonNull IRemoteTransition remoteTransition, @Nullable String debugName) { + public RemoteTransition(@NonNull IRemoteTransition remoteTransition, + @Nullable String debugName) { this(remoteTransition, null /* appThread */, debugName); } @@ -66,10 +63,12 @@ public final class RemoteTransition implements Parcelable { /** * Creates a new RemoteTransition. * - * @param remoteTransition The actual remote-transition interface used to run the transition - * animation. - * @param appThread The application thread that will be running the remote transition. - * @param debugName A name for this that can be used for debugging. + * @param remoteTransition + * The actual remote-transition interface used to run the transition animation. + * @param appThread + * The application thread that will be running the remote transition. + * @param debugName + * A name for this that can be used for debugging. * @hide */ public RemoteTransition( @@ -87,7 +86,6 @@ public final class RemoteTransition implements Parcelable { /** * The actual remote-transition interface used to run the transition animation. - * * @hide */ public @NonNull IRemoteTransition getRemoteTransition() { @@ -96,21 +94,21 @@ public final class RemoteTransition implements Parcelable { /** * The application thread that will be running the remote transition. - * * @hide */ public @Nullable IApplicationThread getAppThread() { return mAppThread; } - /** A name for this that can be used for debugging. */ + /** + * A name for this that can be used for debugging. + */ public @Nullable String getDebugName() { return mDebugName; } /** * The actual remote-transition interface used to run the transition animation. - * * @hide */ public @NonNull RemoteTransition setRemoteTransition(@NonNull IRemoteTransition value) { @@ -122,7 +120,6 @@ public final class RemoteTransition implements Parcelable { /** * The application thread that will be running the remote transition. - * * @hide */ public @NonNull RemoteTransition setAppThread(@NonNull IApplicationThread value) { @@ -130,7 +127,9 @@ public final class RemoteTransition implements Parcelable { return this; } - /** A name for this that can be used for debugging. */ + /** + * A name for this that can be used for debugging. + */ public @NonNull RemoteTransition setDebugName(@NonNull String value) { mDebugName = value; return this; @@ -141,16 +140,11 @@ public final class RemoteTransition implements Parcelable { // You can override field toString logic by defining methods like: // String fieldNameToString() { ... } - return "RemoteTransition { " - + "remoteTransition = " - + mRemoteTransition - + ", " - + "appThread = " - + mAppThread - + ", " - + "debugName = " - + mDebugName - + " }"; + return "RemoteTransition { " + + "remoteTransition = " + mRemoteTransition + ", " + + "appThread = " + mAppThread + ", " + + "debugName = " + mDebugName + + " }"; } @Override @@ -168,9 +162,7 @@ public final class RemoteTransition implements Parcelable { } @Override - public int describeContents() { - return 0; - } + public int describeContents() { return 0; } /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @@ -179,12 +171,8 @@ public final class RemoteTransition implements Parcelable { // static FieldType unparcelFieldName(Parcel in) { ... } byte flg = in.readByte(); - IRemoteTransition remoteTransition = - IRemoteTransition.Stub.asInterface(in.readStrongBinder()); - IApplicationThread appThread = - (flg & 0x2) == 0 - ? null - : IApplicationThread.Stub.asInterface(in.readStrongBinder()); + IRemoteTransition remoteTransition = IRemoteTransition.Stub.asInterface(in.readStrongBinder()); + IApplicationThread appThread = (flg & 0x2) == 0 ? null : IApplicationThread.Stub.asInterface(in.readStrongBinder()); String debugName = (flg & 0x4) == 0 ? null : in.readString(); this.mRemoteTransition = remoteTransition; @@ -194,16 +182,16 @@ public final class RemoteTransition implements Parcelable { this.mDebugName = debugName; } - public static final @NonNull Parcelable.Creator CREATOR = - new Parcelable.Creator() { - @Override - public RemoteTransition[] newArray(int size) { - return new RemoteTransition[size]; - } + public static final @NonNull Parcelable.Creator CREATOR + = new Parcelable.Creator() { + @Override + public RemoteTransition[] newArray(int size) { + return new RemoteTransition[size]; + } - @Override - public RemoteTransition createFromParcel(@NonNull android.os.Parcel in) { - return new RemoteTransition(in); - } - }; + @Override + public RemoteTransition createFromParcel(@NonNull android.os.Parcel in) { + return new RemoteTransition(in); + } + }; } diff --git a/compatLib/src/main/java/android/window/RemoteTransitionStub.java b/compatLib/src/main/java/android/window/RemoteTransitionStub.java index b3a14ea484..4a97b1e241 100644 --- a/compatLib/src/main/java/android/window/RemoteTransitionStub.java +++ b/compatLib/src/main/java/android/window/RemoteTransitionStub.java @@ -27,25 +27,21 @@ import android.view.SurfaceControl; */ public abstract class RemoteTransitionStub extends IRemoteTransition.Stub { @Override - public void mergeAnimation( - IBinder transition, - TransitionInfo info, - SurfaceControl.Transaction t, - IBinder mergeTarget, - IRemoteTransitionFinishedCallback finishCallback) - throws RemoteException {} + public void mergeAnimation(IBinder transition, TransitionInfo info, + SurfaceControl.Transaction t, IBinder mergeTarget, + IRemoteTransitionFinishedCallback finishCallback) throws RemoteException {} + @Override - public void takeOverAnimation( - IBinder transition, - TransitionInfo info, + public void takeOverAnimation(IBinder transition, TransitionInfo info, SurfaceControl.Transaction startTransaction, IRemoteTransitionFinishedCallback finishCallback, - WindowAnimationState[] states) - throws RemoteException { + WindowAnimationState[] states) throws RemoteException { throw new RemoteException("Takeovers are not supported by this IRemoteTransition"); } + @Override - public void onTransitionConsumed(IBinder transition, boolean aborted) throws RemoteException {} + public void onTransitionConsumed(IBinder transition, boolean aborted) + throws RemoteException {} } diff --git a/compatLib/src/main/java/android/window/TransitionFilter.aidl b/compatLib/src/main/java/android/window/TransitionFilter.aidl index 3c3bb6acdc..19c76d153b 100644 --- a/compatLib/src/main/java/android/window/TransitionFilter.aidl +++ b/compatLib/src/main/java/android/window/TransitionFilter.aidl @@ -16,4 +16,4 @@ package android.window; -parcelable TransitionFilter; \ No newline at end of file +parcelable TransitionFilter; diff --git a/compatLib/src/main/java/android/window/TransitionFilter.java b/compatLib/src/main/java/android/window/TransitionFilter.java index 2152c6e894..d8d20119a6 100644 --- a/compatLib/src/main/java/android/window/TransitionFilter.java +++ b/compatLib/src/main/java/android/window/TransitionFilter.java @@ -17,6 +17,7 @@ package android.window; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; +import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.WindowManager.TransitionType; import android.annotation.IntDef; @@ -32,7 +33,8 @@ import android.view.WindowManager; /** * A parcelable filter that can be used for rerouting transitions to a remote. This is a local - * representation so that the transition system doesn't need to make blocking queries over binder. + * representation so that the transition system doesn't need to make blocking queries over + * binder. * * @hide */ @@ -40,17 +42,14 @@ public final class TransitionFilter implements Parcelable { /** The associated requirement doesn't care about the z-order. */ public static final int CONTAINER_ORDER_ANY = 0; - /** The associated requirement only matches the top-most (z-order) container. */ public static final int CONTAINER_ORDER_TOP = 1; /** @hide */ - @IntDef( - prefix = {"CONTAINER_ORDER_"}, - value = { - CONTAINER_ORDER_ANY, - CONTAINER_ORDER_TOP, - }) + @IntDef(prefix = { "CONTAINER_ORDER_" }, value = { + CONTAINER_ORDER_ANY, + CONTAINER_ORDER_TOP, + }) public @interface ContainerOrder {} /** @@ -65,10 +64,13 @@ public final class TransitionFilter implements Parcelable { /** All flags must NOT be set on a transition. */ public @WindowManager.TransitionFlags int mNotFlags = 0; - /** A list of required changes. To pass, a transition must meet all requirements. */ + /** + * A list of required changes. To pass, a transition must meet all requirements. + */ @Nullable public Requirement[] mRequirements = null; - public TransitionFilter() {} + public TransitionFilter() { + } private TransitionFilter(Parcel in) { mTypeSet = in.createIntArray(); @@ -77,9 +79,7 @@ public final class TransitionFilter implements Parcelable { mRequirements = in.createTypedArray(Requirement.CREATOR); } - /** - * @return true if `info` meets all the requirements to pass this filter. - */ + /** @return true if `info` meets all the requirements to pass this filter. */ public boolean matches(@NonNull TransitionInfo info) { if (mTypeSet != null) { // non-null typeset, so make sure info is one of the types. @@ -184,7 +184,14 @@ public final class TransitionFilter implements Parcelable { public ComponentName mTopActivity; public IBinder mLaunchCookie; - public Requirement() {} + /** If non-null, requires the change to specifically have or not-have a custom animation. */ + public Boolean mCustomAnimation = null; + public IBinder mTaskFragmentToken = null; + + public int mWindowingMode = WINDOWING_MODE_UNDEFINED; + + public Requirement() { + } private Requirement(Parcel in) { mActivityType = in.readInt(); @@ -196,12 +203,23 @@ public final class TransitionFilter implements Parcelable { mOrder = in.readInt(); mTopActivity = in.readTypedObject(ComponentName.CREATOR); mLaunchCookie = in.readStrongBinder(); + // 0: null, 1: false, 2: true + final int customAnimRaw = in.readInt(); + mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2); + mTaskFragmentToken = in.readStrongBinder(); + mWindowingMode = in.readInt(); } /** Go through changes and find if at-least one change matches this filter */ boolean matches(@NonNull TransitionInfo info) { for (int i = info.getChanges().size() - 1; i >= 0; --i) { final TransitionInfo.Change change = info.getChanges().get(i); + + if (mTaskFragmentToken != null + && !mTaskFragmentToken.equals(change.getTaskFragmentToken())) { + continue; + } + if (mMustBeIndependent && !TransitionInfo.isIndependent(change, info)) { // Only look at independent animating windows. continue; @@ -237,13 +255,33 @@ public final class TransitionFilter implements Parcelable { if (!matchesCookie(change.getTaskInfo())) { continue; } + if (mCustomAnimation != null + // only applies to activity/task + && (change.getTaskInfo() != null + || change.getActivityComponent() != null)) { + final TransitionInfo.AnimationOptions opts = change.getAnimationOptions(); + if (opts != null) { + boolean canActuallyOverride = change.getTaskInfo() == null + || opts.getOverrideTaskTransition(); + if (mCustomAnimation != canActuallyOverride) { + continue; + } + } else if (mCustomAnimation) { + continue; + } + } + if (mWindowingMode != WINDOWING_MODE_UNDEFINED) { + if (change.getTaskInfo() == null + || change.getTaskInfo().getWindowingMode() != mWindowingMode) { + continue; + } + } return true; } return false; } - private boolean matchesTopActivity( - ActivityManager.RunningTaskInfo taskInfo, + private boolean matchesTopActivity(ActivityManager.RunningTaskInfo taskInfo, @Nullable ComponentName activityComponent) { if (mTopActivity == null) return true; if (activityComponent != null) { @@ -287,6 +325,10 @@ public final class TransitionFilter implements Parcelable { dest.writeInt(mOrder); dest.writeTypedObject(mTopActivity, flags); dest.writeStrongBinder(mLaunchCookie); + int customAnimRaw = mCustomAnimation == null ? 0 : (mCustomAnimation ? 2 : 1); + dest.writeInt(customAnimRaw); + dest.writeStrongBinder(mTaskFragmentToken); + dest.writeInt(mWindowingMode); } @NonNull @@ -328,6 +370,14 @@ public final class TransitionFilter implements Parcelable { out.append(" order=" + containerOrderToString(mOrder)); out.append(" topActivity=").append(mTopActivity); out.append(" launchCookie=").append(mLaunchCookie); + if (mCustomAnimation != null) { + out.append(" customAnim=").append(mCustomAnimation.booleanValue()); + } + if (mTaskFragmentToken != null) { + out.append(" taskFragmentToken=").append(mTaskFragmentToken); + } + out.append(" windowingMode=" + + WindowConfiguration.windowingModeToString(mWindowingMode)); out.append("}"); return out.toString(); } @@ -335,10 +385,8 @@ public final class TransitionFilter implements Parcelable { private static String containerOrderToString(int order) { switch (order) { - case CONTAINER_ORDER_ANY: - return "ANY"; - case CONTAINER_ORDER_TOP: - return "TOP"; + case CONTAINER_ORDER_ANY: return "ANY"; + case CONTAINER_ORDER_TOP: return "TOP"; } return "UNKNOWN(" + order + ")"; } diff --git a/compatLib/src/main/java/android/window/TransitionInfo.aidl b/compatLib/src/main/java/android/window/TransitionInfo.aidl index a3fa1c8641..6c33e9737f 100644 --- a/compatLib/src/main/java/android/window/TransitionInfo.aidl +++ b/compatLib/src/main/java/android/window/TransitionInfo.aidl @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package android.window; + parcelable TransitionInfo; -parcelable TransitionInfo.Change; \ No newline at end of file +parcelable TransitionInfo.Change; diff --git a/compatLib/src/main/java/android/window/TransitionInfo.java b/compatLib/src/main/java/android/window/TransitionInfo.java index 33bfe6b8f3..3e87f7a62b 100644 --- a/compatLib/src/main/java/android/window/TransitionInfo.java +++ b/compatLib/src/main/java/android/window/TransitionInfo.java @@ -29,6 +29,7 @@ import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED; import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CLOSE; +import static android.view.WindowManager.TRANSIT_FLAG_AOD_APPEARING; import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_APPEARING; import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_NONE; @@ -49,12 +50,14 @@ import android.content.ComponentName; import android.graphics.Point; import android.graphics.Rect; import android.hardware.HardwareBuffer; +import android.os.BinderProxy; +import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; import android.view.Surface; import android.view.SurfaceControl; import android.view.WindowManager; -import com.android.window.flags.Flags; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -63,7 +66,6 @@ import java.util.Objects; /** * Used to communicate information about what is changing during a transition to a TransitionPlayer. - * * @hide */ public final class TransitionInfo implements Parcelable { @@ -71,21 +73,18 @@ public final class TransitionInfo implements Parcelable { /** * Modes are only a sub-set of all the transit-types since they are per-container - * * @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef( - prefix = {"TRANSIT_"}, - value = { - TRANSIT_NONE, - TRANSIT_OPEN, - TRANSIT_CLOSE, - // Note: to_front/to_back really mean show/hide respectively at the container level. - TRANSIT_TO_FRONT, - TRANSIT_TO_BACK, - TRANSIT_CHANGE - }) + @IntDef(prefix = { "TRANSIT_" }, value = { + TRANSIT_NONE, + TRANSIT_OPEN, + TRANSIT_CLOSE, + // Note: to_front/to_back really mean show/hide respectively at the container level. + TRANSIT_TO_FRONT, + TRANSIT_TO_BACK, + TRANSIT_CHANGE + }) public @interface TransitionMode {} /** No flags */ @@ -113,8 +112,8 @@ public final class TransitionInfo implements Parcelable { // TODO(b/194540864): Once we can include all windows in transition, then replace this with // something like FLAG_IS_SYSTEM_ALERT instead. Then we can do mixed rotations. /** - * Only for IS_DISPLAY containers. Is set if the display has system alert windows. This is used - * to prevent seamless rotation. + * Only for IS_DISPLAY containers. Is set if the display has system alert windows. This is + * used to prevent seamless rotation. */ public static final int FLAG_DISPLAY_HAS_ALERT_WINDOWS = 1 << 7; @@ -137,9 +136,9 @@ public final class TransitionInfo implements Parcelable { public static final int FLAG_CROSS_PROFILE_WORK_THUMBNAIL = 1 << 13; /** - * Whether the window is covered by an app starting window. This is different from {@link - * #FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT} which is only set on the Activity window that - * contains the starting window. + * Whether the window is covered by an app starting window. This is different from + * {@link #FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT} which is only set on the Activity window + * that contains the starting window. */ public static final int FLAG_IS_BEHIND_STARTING_WINDOW = 1 << 14; @@ -170,8 +169,11 @@ public final class TransitionInfo implements Parcelable { /** This change represents its start configuration for the duration of the animation. */ public static final int FLAG_CONFIG_AT_END = 1 << 22; + /** This change represents one of a Task Display Area. */ + public static final int FLAG_IS_TASK_DISPLAY_AREA = 1 << 23; + /** The first unused bit. This can be used by remotes to attach custom flags to this change. */ - public static final int FLAG_FIRST_CUSTOM = 1 << 23; + public static final int FLAG_FIRST_CUSTOM = 1 << 24; /** The change belongs to a window that won't contain activities. */ public static final int FLAGS_IS_NON_APP_WINDOW = @@ -182,35 +184,33 @@ public final class TransitionInfo implements Parcelable { /** @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef( - prefix = {"FLAG_"}, - value = { - FLAG_NONE, - FLAG_SHOW_WALLPAPER, - FLAG_IS_WALLPAPER, - FLAG_TRANSLUCENT, - FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT, - FLAG_IS_VOICE_INTERACTION, - FLAG_IS_DISPLAY, - FLAG_DISPLAY_HAS_ALERT_WINDOWS, - FLAG_IS_INPUT_METHOD, - FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY, - FLAG_FILLS_TASK, - FLAG_WILL_IME_SHOWN, - FLAG_CROSS_PROFILE_OWNER_THUMBNAIL, - FLAG_CROSS_PROFILE_WORK_THUMBNAIL, - FLAG_IS_BEHIND_STARTING_WINDOW, - FLAG_IS_OCCLUDED, - FLAG_IS_SYSTEM_WINDOW, - FLAG_BACK_GESTURE_ANIMATED, - FLAG_NO_ANIMATION, - FLAG_TASK_LAUNCHING_BEHIND, - FLAG_MOVED_TO_TOP, - FLAG_SYNC, - FLAG_CONFIG_AT_END, - FLAG_FIRST_CUSTOM - }, - flag = true) + @IntDef(prefix = { "FLAG_" }, flag = true, value = { + FLAG_NONE, + FLAG_SHOW_WALLPAPER, + FLAG_IS_WALLPAPER, + FLAG_TRANSLUCENT, + FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT, + FLAG_IS_VOICE_INTERACTION, + FLAG_IS_DISPLAY, + FLAG_DISPLAY_HAS_ALERT_WINDOWS, + FLAG_IS_INPUT_METHOD, + FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY, + FLAG_FILLS_TASK, + FLAG_WILL_IME_SHOWN, + FLAG_CROSS_PROFILE_OWNER_THUMBNAIL, + FLAG_CROSS_PROFILE_WORK_THUMBNAIL, + FLAG_IS_BEHIND_STARTING_WINDOW, + FLAG_IS_OCCLUDED, + FLAG_IS_SYSTEM_WINDOW, + FLAG_BACK_GESTURE_ANIMATED, + FLAG_NO_ANIMATION, + FLAG_TASK_LAUNCHING_BEHIND, + FLAG_MOVED_TO_TOP, + FLAG_SYNC, + FLAG_CONFIG_AT_END, + FLAG_IS_TASK_DISPLAY_AREA, + FLAG_FIRST_CUSTOM + }) public @interface ChangeFlags {} private final @TransitionType int mType; @@ -219,9 +219,6 @@ public final class TransitionInfo implements Parcelable { private final ArrayList mChanges = new ArrayList<>(); private final ArrayList mRoots = new ArrayList<>(); - // TODO(b/327332488): Clean-up usages after the flag is fully enabled. - @Deprecated private AnimationOptions mOptions; - /** This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work! */ private int mDebugId = -1; @@ -236,7 +233,6 @@ public final class TransitionInfo implements Parcelable { mFlags = in.readInt(); in.readTypedList(mChanges, Change.CREATOR); in.readTypedList(mRoots, Root.CREATOR); - mOptions = in.readTypedObject(AnimationOptions.CREATOR); mDebugId = in.readInt(); mTrack = in.readInt(); } @@ -248,7 +244,6 @@ public final class TransitionInfo implements Parcelable { dest.writeInt(mFlags); dest.writeTypedList(mChanges); dest.writeTypedList(mRoots, flags); - dest.writeTypedObject(mOptions, flags); dest.writeInt(mDebugId); dest.writeInt(mTrack); } @@ -273,33 +268,17 @@ public final class TransitionInfo implements Parcelable { return 0; } - /** - * @see #getRoot - */ - public void addRootLeash( - int displayId, @NonNull SurfaceControl leash, int offsetLeft, int offsetTop) { + /** @see #getRoot */ + public void addRootLeash(int displayId, @NonNull SurfaceControl leash, + int offsetLeft, int offsetTop) { mRoots.add(new Root(displayId, leash, offsetLeft, offsetTop)); } - /** - * @see #getRoot - */ + /** @see #getRoot */ public void addRoot(@NonNull Root other) { mRoots.add(other); } - /** - * @deprecated Set {@link AnimationOptions} to change. This method is only used if {@link - * Flags#FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE} is disabled. - */ - @Deprecated - public void setAnimationOptions(@Nullable AnimationOptions options) { - if (Flags.moveAnimationOptionsToChange()) { - return; - } - mOptions = options; - } - public @TransitionType int getType() { return mType; } @@ -314,7 +293,7 @@ public final class TransitionInfo implements Parcelable { /** * @return The number of animation roots. Most transitions should have 1, but there may be more - * in some cases (such as a transition spanning multiple displays). + * in some cases (such as a transition spanning multiple displays). */ public int getRootCount() { return mRoots.size(); @@ -342,9 +321,10 @@ public final class TransitionInfo implements Parcelable { /** * @return a surfacecontrol that can serve as a parent surfacecontrol for all the changing - * participants to animate within. This will generally be placed at the highest-z-order - * shared ancestor of all participants. While this is non-null, it's possible for the - * rootleash to be invalid if the transition is a no-op. + * participants to animate within. This will generally be placed at the highest-z-order + * shared ancestor of all participants. While this is non-null, it's possible for the rootleash + * to be invalid if the transition is a no-op. + * * @deprecated Use {@link #getRoot} instead. This call assumes there is only one root. */ @Deprecated @@ -354,25 +334,15 @@ public final class TransitionInfo implements Parcelable { throw new IllegalStateException("Trying to get a root leash from a no-op transition."); } if (mRoots.size() > 1) { - android.util.Log.e( - TAG, "Assuming one animation root when there are more.", new Throwable()); + android.util.Log.e(TAG, "Assuming one animation root when there are more.", + new Throwable()); } return mRoots.get(0).mLeash; } /** - * @deprecated Use {@link Change#getAnimationOptions()} instead. This method is called only if - * {@link Flags#FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE} is disabled. - */ - @Deprecated - @Nullable - public AnimationOptions getAnimationOptions() { - return mOptions; - } - - /** - * @return the list of {@link Change}s in this transition. The list is sorted top-to-bottom in Z - * (meaning index 0 is the top-most container). + * @return the list of {@link Change}s in this transition. The list is sorted top-to-bottom + * in Z (meaning index 0 is the top-most container). */ @NonNull public List getChanges() { @@ -380,7 +350,8 @@ public final class TransitionInfo implements Parcelable { } /** - * @return the Change that a window is undergoing or {@code null} if not directly represented. + * @return the Change that a window is undergoing or {@code null} if not directly + * represented. */ @Nullable public Change getChange(@NonNull WindowContainerToken token) { @@ -392,22 +363,26 @@ public final class TransitionInfo implements Parcelable { return null; } - /** Add a {@link Change} to this transition. */ + /** + * Add a {@link Change} to this transition. + */ public void addChange(@NonNull Change change) { mChanges.add(change); } /** - * Whether this transition contains any changes to the window hierarchy, including keyguard - * visibility. + * Whether this transition contains any changes to the window hierarchy, + * including keyguard visibility. */ public boolean hasChangesOrSideEffects() { - return !mChanges.isEmpty() - || isKeyguardGoingAway() - || (mFlags & TRANSIT_FLAG_KEYGUARD_APPEARING) != 0; + return !mChanges.isEmpty() || isKeyguardGoingAway() + || (mFlags & TRANSIT_FLAG_KEYGUARD_APPEARING) != 0 + || (mFlags & TRANSIT_FLAG_AOD_APPEARING) != 0; } - /** Whether this transition includes keyguard going away. */ + /** + * Whether this transition includes keyguard going away. + */ public boolean isKeyguardGoingAway() { return (mFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0; } @@ -423,8 +398,8 @@ public final class TransitionInfo implements Parcelable { } /** - * Set an arbitrary "debug" id for this info. This id will not be used for any "real work", it - * is just for debugging and logging. + * Set an arbitrary "debug" id for this info. This id will not be used for any "real work", + * it is just for debugging and logging. */ public void setDebugId(int id) { mDebugId = id; @@ -442,7 +417,6 @@ public final class TransitionInfo implements Parcelable { /** * Returns a string representation of this transition info. - * * @hide */ public String toString(@NonNull String prefix) { @@ -451,17 +425,8 @@ public final class TransitionInfo implements Parcelable { final String changesLineStart = shouldPrettyPrint ? "\n" + prefix : ""; final String perChangeLineStart = shouldPrettyPrint ? "\n" + innerPrefix : ""; StringBuilder sb = new StringBuilder(); - sb.append("{id=") - .append(mDebugId) - .append(" t=") - .append(transitTypeToString(mType)) - .append(" f=0x") - .append(Integer.toHexString(mFlags)) - .append(" trk=") - .append(mTrack); - if (mOptions != null) { - sb.append(" opt=").append(mOptions); - } + sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType)) + .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack); sb.append(" r=["); for (int i = 0; i < mRoots.size(); ++i) { if (i > 0) { @@ -486,21 +451,14 @@ public final class TransitionInfo implements Parcelable { /** Converts a transition mode/action to its string representation. */ @NonNull public static String modeToString(@TransitionMode int mode) { - switch (mode) { - case TRANSIT_NONE: - return "NONE"; - case TRANSIT_OPEN: - return "OPEN"; - case TRANSIT_CLOSE: - return "CLOSE"; - case TRANSIT_TO_FRONT: - return "TO_FRONT"; - case TRANSIT_TO_BACK: - return "TO_BACK"; - case TRANSIT_CHANGE: - return "CHANGE"; - default: - return ""; + switch(mode) { + case TRANSIT_NONE: return "NONE"; + case TRANSIT_OPEN: return "OPEN"; + case TRANSIT_CLOSE: return "CLOSE"; + case TRANSIT_TO_FRONT: return "TO_FRONT"; + case TRANSIT_TO_BACK: return "TO_BACK"; + case TRANSIT_CHANGE: return "CHANGE"; + default: return ""; } } @@ -569,15 +527,18 @@ public final class TransitionInfo implements Parcelable { if ((flags & FLAG_MOVED_TO_TOP) != 0) { sb.append(sb.length() == 0 ? "" : "|").append("MOVE_TO_TOP"); } + if ((flags & FLAG_IS_TASK_DISPLAY_AREA) != 0) { + sb.append(sb.length() == 0 ? "" : "|").append("FLAG_IS_TASK_DISPLAY_AREA"); + } return sb.toString(); } /** - * Indication that `change` is independent of parents (ie. it has a different type of transition - * vs. "going along for the ride") + * Indication that `change` is independent of parents (ie. it has a different type of + * transition vs. "going along for the ride") */ - public static boolean isIndependent( - @NonNull TransitionInfo.Change change, @NonNull TransitionInfo info) { + public static boolean isIndependent(@NonNull TransitionInfo.Change change, + @NonNull TransitionInfo info) { // If the change has no parent (it is root), then it is independent if (change.getParent() == null) return true; @@ -664,8 +625,6 @@ public final class TransitionInfo implements Parcelable { for (int i = 0; i < mRoots.size(); ++i) { out.mRoots.add(mRoots.get(i).localRemoteCopy()); } - // Doesn't have any native stuff, so no need for actual copy - out.mOptions = mOptions; return out; } @@ -680,32 +639,32 @@ public final class TransitionInfo implements Parcelable { private final Rect mStartAbsBounds = new Rect(); private final Rect mEndAbsBounds = new Rect(); private final Point mEndRelOffset = new Point(); + private final Point mEndParentSize = new Point(); private ActivityManager.RunningTaskInfo mTaskInfo = null; private boolean mAllowEnterPip; private int mStartDisplayId = INVALID_DISPLAY; private int mEndDisplayId = INVALID_DISPLAY; private @Surface.Rotation int mStartRotation = ROTATION_UNDEFINED; private @Surface.Rotation int mEndRotation = ROTATION_UNDEFINED; - /** * The end rotation of the top activity after fixed rotation is finished. If the top * activity is not in fixed rotation, it will be {@link ROTATION_UNDEFINED}. */ private @Surface.Rotation int mEndFixedRotation = ROTATION_UNDEFINED; - private int mRotationAnimation = ROTATION_ANIMATION_UNSPECIFIED; private @ColorInt int mBackgroundColor; private SurfaceControl mSnapshot = null; private float mSnapshotLuma; - private ComponentName mActivityComponent = null; + private ActivityTransitionInfo mActivityTransitionInfo = null; private AnimationOptions mAnimationOptions = null; + private IBinder mTaskFragmentToken = null; public Change(@Nullable WindowContainerToken container, @NonNull SurfaceControl leash) { mContainer = container; mLeash = leash; } - private Change(Parcel in) { + private Change(@NonNull Parcel in) { mContainer = in.readTypedObject(WindowContainerToken.CREATOR); mParent = in.readTypedObject(WindowContainerToken.CREATOR); mLastParent = in.readTypedObject(WindowContainerToken.CREATOR); @@ -716,6 +675,7 @@ public final class TransitionInfo implements Parcelable { mStartAbsBounds.readFromParcel(in); mEndAbsBounds.readFromParcel(in); mEndRelOffset.readFromParcel(in); + mEndParentSize.readFromParcel(in); mTaskInfo = in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR); mAllowEnterPip = in.readBoolean(); mStartDisplayId = in.readInt(); @@ -727,8 +687,9 @@ public final class TransitionInfo implements Parcelable { mBackgroundColor = in.readInt(); mSnapshot = in.readTypedObject(SurfaceControl.CREATOR); mSnapshotLuma = in.readFloat(); - mActivityComponent = in.readTypedObject(ComponentName.CREATOR); + mActivityTransitionInfo = in.readTypedObject(ActivityTransitionInfo.CREATOR); mAnimationOptions = in.readTypedObject(AnimationOptions.CREATOR); + mTaskFragmentToken = in.readStrongBinder(); } private Change localRemoteCopy() { @@ -740,6 +701,7 @@ public final class TransitionInfo implements Parcelable { out.mStartAbsBounds.set(mStartAbsBounds); out.mEndAbsBounds.set(mEndAbsBounds); out.mEndRelOffset.set(mEndRelOffset); + out.mEndParentSize.set(mEndParentSize); out.mTaskInfo = mTaskInfo; out.mAllowEnterPip = mAllowEnterPip; out.mStartDisplayId = mStartDisplayId; @@ -751,8 +713,11 @@ public final class TransitionInfo implements Parcelable { out.mBackgroundColor = mBackgroundColor; out.mSnapshot = mSnapshot != null ? new SurfaceControl(mSnapshot, "localRemote") : null; out.mSnapshotLuma = mSnapshotLuma; - out.mActivityComponent = mActivityComponent; + if (mActivityTransitionInfo != null) { + out.mActivityTransitionInfo = new ActivityTransitionInfo(mActivityTransitionInfo); + } out.mAnimationOptions = mAnimationOptions; + out.mTaskFragmentToken = mTaskFragmentToken; return out; } @@ -800,8 +765,15 @@ public final class TransitionInfo implements Parcelable { } /** - * Sets the taskinfo of this container if this is a task. WARNING: this takes the reference, - * so don't modify it afterwards. + * Sets the size of its parent container after the change. + */ + public void setEndParentSize(int width, int height) { + mEndParentSize.set(width, height); + } + + /** + * Sets the taskinfo of this container if this is a task. WARNING: this takes the + * reference, so don't modify it afterwards. */ public void setTaskInfo(@Nullable ActivityManager.RunningTaskInfo taskInfo) { mTaskInfo = taskInfo; @@ -848,22 +820,27 @@ public final class TransitionInfo implements Parcelable { mSnapshotLuma = luma; } - /** Sets the component-name of the container. Container must be an Activity. */ - public void setActivityComponent(@Nullable ComponentName component) { - mActivityComponent = component; + /** Sets the activity-specific transition information. Container must be an Activity. */ + public void setActivityTransitionInfo(@Nullable ActivityTransitionInfo info) { + mActivityTransitionInfo = info; } - /** Sets {@link AnimationOptions} to override animation. */ + /** + * Sets {@link AnimationOptions} to override animation. + */ public void setAnimationOptions(@Nullable AnimationOptions options) { - if (!Flags.moveAnimationOptionsToChange()) { - return; - } mAnimationOptions = options; } /** - * @return the container that is changing. May be null if non-remotable (eg. activity) + * Sets the client-defined TaskFragment token. Only set this if the window is a + * client-organized TaskFragment. */ + public void setTaskFragmentToken(@Nullable IBinder token) { + mTaskFragmentToken = token; + } + + /** @return the container that is changing. May be null if non-remotable (eg. activity) */ @Nullable public WindowContainerToken getContainer() { return mContainer; @@ -871,7 +848,7 @@ public final class TransitionInfo implements Parcelable { /** * @return the parent of the changing container. This is the parent within the participants, - * not necessarily the actual parent. + * not necessarily the actual parent. */ @Nullable public WindowContainerToken getParent() { @@ -879,27 +856,22 @@ public final class TransitionInfo implements Parcelable { } /** - * @return the parent of the changing container before the transition if it is reparented in - * the transition. The parent window may not be collected in the transition as a - * participant, and it may have been detached from the display. {@code null} if the - * changing container has not been reparented in the transition, or if the parent is not - * organizable. + * @return the parent of the changing container before the transition if it is reparented + * in the transition. The parent window may not be collected in the transition as a + * participant, and it may have been detached from the display. {@code null} if the changing + * container has not been reparented in the transition, or if the parent is not organizable. */ @Nullable public WindowContainerToken getLastParent() { return mLastParent; } - /** - * @return which action this change represents. - */ + /** @return which action this change represents. */ public @TransitionMode int getMode() { return mMode; } - /** - * @return the flags for this change. - */ + /** @return the flags for this change. */ public @ChangeFlags int getFlags() { return mFlags; } @@ -916,7 +888,7 @@ public final class TransitionInfo implements Parcelable { /** * @return the bounds of the container before the change. It may be empty if the container - * is coming into existence. + * is coming into existence. */ @NonNull public Rect getStartAbsBounds() { @@ -924,8 +896,8 @@ public final class TransitionInfo implements Parcelable { } /** - * @return the bounds of the container after the change. It may be empty if the container is - * disappearing. + * @return the bounds of the container after the change. It may be empty if the container + * is disappearing. */ @NonNull public Rect getEndAbsBounds() { @@ -941,16 +913,20 @@ public final class TransitionInfo implements Parcelable { } /** - * @return the leash or surface to animate for this container + * Returns the size of parent container after the change. */ @NonNull + public Point getEndParentSize() { + return mEndParentSize; + } + + /** @return the leash or surface to animate for this container */ + @NonNull public SurfaceControl getLeash() { return mLeash; } - /** - * @return the task info or null if this isn't a task - */ + /** @return the task info or null if this isn't a task */ @Nullable public ActivityManager.RunningTaskInfo getTaskInfo() { return mTaskInfo; @@ -983,50 +959,60 @@ public final class TransitionInfo implements Parcelable { return mEndFixedRotation; } - /** - * @return the rotation animation. - */ + /** @return the rotation animation. */ public int getRotationAnimation() { return mRotationAnimation; } - /** - * @return get the background color of this change's container. - */ + /** @return get the background color of this change's container. */ @ColorInt public int getBackgroundColor() { return mBackgroundColor; } - /** - * @return a snapshot surface (if applicable). - */ + /** @return a snapshot surface (if applicable). */ @Nullable public SurfaceControl getSnapshot() { return mSnapshot; } - /** - * @return the luma calculated for the snapshot surface (if applicable). - */ + /** @return the luma calculated for the snapshot surface (if applicable). */ public float getSnapshotLuma() { return mSnapshotLuma; } - /** - * @return the component-name of this container (if it is an activity). - */ + /** @return the component-name of this container (if it is an activity). */ @Nullable public ComponentName getActivityComponent() { - return mActivityComponent; + return mActivityTransitionInfo != null ? mActivityTransitionInfo.getComponent() : null; } - /** Returns the {@link AnimationOptions}. */ + /** + * @return the activity-specific transition information, or {@code null} if this container + * is not an activity. + */ + @Nullable + public ActivityTransitionInfo getActivityTransitionInfo() { + return mActivityTransitionInfo; + } + + /** + * Returns the {@link AnimationOptions}. + */ @Nullable public AnimationOptions getAnimationOptions() { return mAnimationOptions; } + /** + * Returns the client-defined TaskFragment token. {@code null} if this window is not a + * client-organized TaskFragment. + */ + @Nullable + public IBinder getTaskFragmentToken() { + return mTaskFragmentToken; + } + /** @hide */ @Override public void writeToParcel(@NonNull Parcel dest, int flags) { @@ -1039,6 +1025,7 @@ public final class TransitionInfo implements Parcelable { mStartAbsBounds.writeToParcel(dest, flags); mEndAbsBounds.writeToParcel(dest, flags); mEndRelOffset.writeToParcel(dest, flags); + mEndParentSize.writeToParcel(dest, flags); dest.writeTypedObject(mTaskInfo, flags); dest.writeBoolean(mAllowEnterPip); dest.writeInt(mStartDisplayId); @@ -1050,8 +1037,9 @@ public final class TransitionInfo implements Parcelable { dest.writeInt(mBackgroundColor); dest.writeTypedObject(mSnapshot, flags); dest.writeFloat(mSnapshotLuma); - dest.writeTypedObject(mActivityComponent, flags); + dest.writeTypedObject(mActivityTransitionInfo, flags); dest.writeTypedObject(mAnimationOptions, flags); + dest.writeStrongBinder(mTaskFragmentToken); } @NonNull @@ -1078,26 +1066,26 @@ public final class TransitionInfo implements Parcelable { public String toString() { final StringBuilder sb = new StringBuilder(); sb.append('{'); - sb.append(mContainer); - sb.append(" m="); - sb.append(modeToString(mMode)); - sb.append(" f="); - sb.append(flagsToString(mFlags)); + if (mContainer != null && !(mContainer.asBinder() instanceof BinderProxy)) { + // Only log the token if it is not a binder proxy and has additional container info + sb.append(mContainer); + sb.append(" "); + } + sb.append("m="); sb.append(modeToString(mMode)); + sb.append(" f="); sb.append(flagsToString(mFlags)); if (mParent != null) { - sb.append(" p="); - sb.append(mParent); + sb.append(" p="); sb.append(mParent); } if (mLeash != null) { - sb.append(" leash="); - sb.append(mLeash); + sb.append(" leash="); sb.append(mLeash); } - sb.append(" sb="); - sb.append(mStartAbsBounds); - sb.append(" eb="); - sb.append(mEndAbsBounds); + sb.append(" sb="); sb.append(mStartAbsBounds); + sb.append(" eb="); sb.append(mEndAbsBounds); if (mEndRelOffset.x != 0 || mEndRelOffset.y != 0) { - sb.append(" eo="); - sb.append(mEndRelOffset); + sb.append(" eo="); sb.append(mEndRelOffset); + } + if (!mEndParentSize.equals(0, 0)) { + sb.append(" epz=").append(mEndParentSize); } sb.append(" d="); if (mStartDisplayId != mEndDisplayId) { @@ -1105,39 +1093,37 @@ public final class TransitionInfo implements Parcelable { } sb.append(mEndDisplayId); if (mStartRotation != mEndRotation) { - sb.append(" r="); - sb.append(mStartRotation); - sb.append("->"); - sb.append(mEndRotation); - sb.append(':'); - sb.append(mRotationAnimation); + sb.append(" r="); sb.append(mStartRotation); + sb.append("->"); sb.append(mEndRotation); + sb.append(':'); sb.append(mRotationAnimation); } if (mEndFixedRotation != ROTATION_UNDEFINED) { - sb.append(" endFixedRotation="); - sb.append(mEndFixedRotation); + sb.append(" endFixedRotation="); sb.append(mEndFixedRotation); } if (mBackgroundColor != 0) { sb.append(" bc=").append(Integer.toHexString(mBackgroundColor)); } if (mSnapshot != null) { - sb.append(" snapshot="); - sb.append(mSnapshot); + sb.append(" snapshot="); sb.append(mSnapshot); } if (mLastParent != null) { - sb.append(" lastParent="); - sb.append(mLastParent); + sb.append(" lastParent="); sb.append(mLastParent); } - if (mActivityComponent != null) { - sb.append(" component="); - sb.append(mActivityComponent.flattenToShortString()); + if (mActivityTransitionInfo != null) { + sb.append(" activity=").append(mActivityTransitionInfo); } if (mTaskInfo != null) { sb.append(" taskParent="); sb.append(mTaskInfo.parentTaskId); + sb.append(" winMode="); + sb.append(mTaskInfo.getWindowingMode()); } if (mAnimationOptions != null) { sb.append(" opt=").append(mAnimationOptions); } + if (mTaskFragmentToken != null) { + sb.append(" taskFragmentToken=").append(mTaskFragmentToken); + } sb.append('}'); return sb.toString(); } @@ -1169,6 +1155,7 @@ public final class TransitionInfo implements Parcelable { // Customize activity transition animation private CustomActivityTransition mCustomActivityOpenTransition; private CustomActivityTransition mCustomActivityCloseTransition; + private int mUserId; private AnimationOptions(int type) { mType = type; @@ -1179,7 +1166,6 @@ public final class TransitionInfo implements Parcelable { mEnterResId = in.readInt(); mChangeResId = in.readInt(); mExitResId = in.readInt(); - mBackgroundColor = in.readInt(); mOverrideTaskTransition = in.readBoolean(); mPackageName = in.readString(); mTransitionBounds.readFromParcel(in); @@ -1187,6 +1173,7 @@ public final class TransitionInfo implements Parcelable { mAnimations = in.readInt(); mCustomActivityOpenTransition = in.readTypedObject(CustomActivityTransition.CREATOR); mCustomActivityCloseTransition = in.readTypedObject(CustomActivityTransition.CREATOR); + mUserId = in.readInt(); } /** Make basic customized animation for a package */ @@ -1213,10 +1200,10 @@ public final class TransitionInfo implements Parcelable { } /** Add customized activity animation attributes */ - public void addCustomActivityTransition( - boolean isOpen, int enterResId, int exitResId, int backgroundColor) { - CustomActivityTransition customTransition = - isOpen ? mCustomActivityOpenTransition : mCustomActivityCloseTransition; + public void addCustomActivityTransition(boolean isOpen, + int enterResId, int exitResId, int backgroundColor) { + CustomActivityTransition customTransition = isOpen + ? mCustomActivityOpenTransition : mCustomActivityCloseTransition; if (customTransition == null) { customTransition = new CustomActivityTransition(); if (isOpen) { @@ -1228,31 +1215,6 @@ public final class TransitionInfo implements Parcelable { customTransition.addCustomActivityTransition(enterResId, exitResId, backgroundColor); } - /** - * Make options for a custom animation based on anim resources. - * - * @param packageName the package name to find the animation resources - * @param enterResId the open animation resources ID - * @param exitResId the close animation resources ID - * @param backgroundColor the background color - * @param overrideTaskTransition whether to override the task transition - */ - @NonNull - public static AnimationOptions makeCustomAnimOptions( - @NonNull String packageName, - @AnimRes int enterResId, - @AnimRes int exitResId, - @ColorInt int backgroundColor, - boolean overrideTaskTransition) { - return makeCustomAnimOptions( - packageName, - enterResId, - DEFAULT_ANIMATION_RESOURCES_ID, - exitResId, - backgroundColor, - overrideTaskTransition); - } - /** * Creates a {@link android.app.ActivityOptions#ANIM_CUSTOM} {@link AnimationOptions}. * @@ -1263,48 +1225,43 @@ public final class TransitionInfo implements Parcelable { * @param overrideTaskTransition indicates whether to override task transition. */ @NonNull - public static AnimationOptions makeCustomAnimOptions( - @NonNull String packageName, - @AnimRes int enterResId, - @AnimRes int changeResId, - @AnimRes int exitResId, - @ColorInt int backgroundColor, + public static AnimationOptions makeCustomAnimOptions(@NonNull String packageName, + @AnimRes int enterResId, @AnimRes int changeResId, @AnimRes int exitResId, boolean overrideTaskTransition) { AnimationOptions options = new AnimationOptions(ANIM_CUSTOM); options.mPackageName = packageName; options.mEnterResId = enterResId; options.mChangeResId = changeResId; options.mExitResId = exitResId; - options.mBackgroundColor = backgroundColor; options.mOverrideTaskTransition = overrideTaskTransition; return options; } /** Make options for a clip-reveal animation. */ @NonNull - public static AnimationOptions makeClipRevealAnimOptions( - int startX, int startY, int width, int height) { + public static AnimationOptions makeClipRevealAnimOptions(int startX, int startY, int width, + int height) { AnimationOptions options = new AnimationOptions(ANIM_CLIP_REVEAL); options.mTransitionBounds.set(startX, startY, startX + width, startY + height); return options; } - /** Make options for a scale-up animation. */ + /** Make options for a scale-up animation with task override option */ @NonNull - public static AnimationOptions makeScaleUpAnimOptions( - int startX, int startY, int width, int height) { + public static AnimationOptions makeScaleUpAnimOptions(int startX, int startY, int width, + int height, boolean overrideTaskTransition) { AnimationOptions options = new AnimationOptions(ANIM_SCALE_UP); options.mTransitionBounds.set(startX, startY, startX + width, startY + height); + options.mOverrideTaskTransition = overrideTaskTransition; return options; } /** Make options for a thumbnail-scaling animation. */ @NonNull - public static AnimationOptions makeThumbnailAnimOptions( - @NonNull HardwareBuffer srcThumb, int startX, int startY, boolean scaleUp) { - AnimationOptions options = - new AnimationOptions( - scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN); + public static AnimationOptions makeThumbnailAnimOptions(@NonNull HardwareBuffer srcThumb, + int startX, int startY, boolean scaleUp) { + AnimationOptions options = new AnimationOptions( + scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN); options.mTransitionBounds.set(startX, startY, startX, startY); options.mThumbnail = srcThumb; return options; @@ -1324,6 +1281,14 @@ public final class TransitionInfo implements Parcelable { return options; } + public void setUserId(int userId) { + mUserId = userId; + } + + public int getUserId() { + return mUserId; + } + public int getType() { return mType; } @@ -1343,10 +1308,6 @@ public final class TransitionInfo implements Parcelable { return mExitResId; } - public @ColorInt int getBackgroundColor() { - return mBackgroundColor; - } - public boolean getOverrideTaskTransition() { return mOverrideTaskTransition; } @@ -1382,7 +1343,6 @@ public final class TransitionInfo implements Parcelable { dest.writeInt(mEnterResId); dest.writeInt(mChangeResId); dest.writeInt(mExitResId); - dest.writeInt(mBackgroundColor); dest.writeBoolean(mOverrideTaskTransition); dest.writeString(mPackageName); mTransitionBounds.writeToParcel(dest, flags); @@ -1390,6 +1350,7 @@ public final class TransitionInfo implements Parcelable { dest.writeInt(mAnimations); dest.writeTypedObject(mCustomActivityOpenTransition, flags); dest.writeTypedObject(mCustomActivityCloseTransition, flags); + dest.writeInt(mUserId); } @NonNull @@ -1447,6 +1408,7 @@ public final class TransitionInfo implements Parcelable { if (mExitResId != DEFAULT_ANIMATION_RESOURCES_ID) { sb.append(" exitResId=").append(mExitResId); } + sb.append(" mUserId=").append(mUserId); sb.append('}'); return sb.toString(); } @@ -1471,7 +1433,6 @@ public final class TransitionInfo implements Parcelable { public int getCustomBackgroundColor() { return mCustomBackgroundColor; } - CustomActivityTransition() {} CustomActivityTransition(Parcel in) { @@ -1519,9 +1480,9 @@ public final class TransitionInfo implements Parcelable { /** * An animation root in a transition. There is one of these for each display that contains * participants. It will be placed, in z-order, right above the top-most participant and at the - * same position in the hierarchy. As a result, if all participants are animating within a part - * of the screen, the root-leash will only be in that part of the screen. In these cases, it's - * relative position (from the screen) is stored in {@link Root#getOffset}. + * same position in the hierarchy. As a result, if all participants are animating within a + * part of the screen, the root-leash will only be in that part of the screen. In these cases, + * it's relative position (from the screen) is stored in {@link Root#getOffset}. */ public static final class Root implements Parcelable { private final int mDisplayId; @@ -1543,28 +1504,22 @@ public final class TransitionInfo implements Parcelable { } private Root localRemoteCopy() { - return new Root( - mDisplayId, new SurfaceControl(mLeash, "localRemote"), mOffset.x, mOffset.y); + return new Root(mDisplayId, new SurfaceControl(mLeash, "localRemote"), + mOffset.x, mOffset.y); } - /** - * @return the id of the display this root is on. - */ + /** @return the id of the display this root is on. */ public int getDisplayId() { return mDisplayId; } - /** - * @return the root's leash. Surfaces should be parented to this while animating. - */ + /** @return the root's leash. Surfaces should be parented to this while animating. */ @NonNull public SurfaceControl getLeash() { return mLeash; } - /** - * @return the offset (relative to its screen) of the root leash. - */ + /** @return the offset (relative to its screen) of the root leash. */ @NonNull public Point getOffset() { return mOffset; diff --git a/compatLib/src/main/java/android/window/WindowAnimationState.aidl b/compatLib/src/main/java/android/window/WindowAnimationState.aidl index 0ad6a04bd6..e662860b87 100644 --- a/compatLib/src/main/java/android/window/WindowAnimationState.aidl +++ b/compatLib/src/main/java/android/window/WindowAnimationState.aidl @@ -33,4 +33,4 @@ parcelable WindowAnimationState { float bottomRightRadius; float bottomLeftRadius; PointF velocityPxPerMs; -} \ No newline at end of file +} diff --git a/compatLib/src/main/java/app/lawnchair/compatlib/ActivityManagerCompat.java b/compatLib/src/main/java/app/lawnchair/compatlib/ActivityManagerCompat.java index 237e91d4ab..caa94ace63 100644 --- a/compatLib/src/main/java/app/lawnchair/compatlib/ActivityManagerCompat.java +++ b/compatLib/src/main/java/app/lawnchair/compatlib/ActivityManagerCompat.java @@ -5,7 +5,7 @@ import android.app.ActivityManager; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Rect; -import android.view.IRecentsAnimationController; +import com.android.wm.shell.recents.IRecentsAnimationController; import android.window.TaskSnapshot; import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/compatLib/src/main/java/app/lawnchair/compatlib/RecentsAnimationRunnerCompat.java b/compatLib/src/main/java/app/lawnchair/compatlib/RecentsAnimationRunnerCompat.java index 42ffcceda7..16702d416d 100644 --- a/compatLib/src/main/java/app/lawnchair/compatlib/RecentsAnimationRunnerCompat.java +++ b/compatLib/src/main/java/app/lawnchair/compatlib/RecentsAnimationRunnerCompat.java @@ -1,14 +1,14 @@ package app.lawnchair.compatlib; import android.graphics.Rect; -import android.view.IRecentsAnimationController; +import com.android.wm.shell.recents.IRecentsAnimationController; import android.view.RemoteAnimationTarget; import android.window.TaskSnapshot; public interface RecentsAnimationRunnerCompat { void onAnimationStart( - IRecentsAnimationController controller, + Object controller, RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, Rect homeContentInsets, diff --git a/compatLib/src/main/java/com/android/wm/shell/recents/IRecentsAnimationController.aidl b/compatLib/src/main/java/com/android/wm/shell/recents/IRecentsAnimationController.aidl new file mode 100644 index 0000000000..bcf7c7402b --- /dev/null +++ b/compatLib/src/main/java/com/android/wm/shell/recents/IRecentsAnimationController.aidl @@ -0,0 +1,2 @@ +package com.android.wm.shell.recents; +parcelable IRecentsAnimationController; diff --git a/systemUI/shared/src/com/android/systemui/shared/navigationbar/KeyButtonRipple.java b/systemUI/shared/src/com/android/systemui/shared/navigationbar/KeyButtonRipple.java index a9efea2dcf..afef2f6c17 100644 --- a/systemUI/shared/src/com/android/systemui/shared/navigationbar/KeyButtonRipple.java +++ b/systemUI/shared/src/com/android/systemui/shared/navigationbar/KeyButtonRipple.java @@ -28,6 +28,8 @@ import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.RecordingCanvas; import android.graphics.drawable.Drawable; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES_FULL; import android.os.Handler; import android.os.Looper; import android.os.Trace; @@ -103,9 +105,11 @@ public class KeyButtonRipple extends Drawable { mMaxWidthResource = maxWidthResource; mMaxWidth = ctx.getResources().getDimensionPixelSize(maxWidthResource); mTargetView = targetView; - mTapTimeoutMillis = Flags.viewconfigurationApis() - ? ViewConfiguration.get(mTargetView.getContext()).getTapTimeoutMillis() - : ViewConfiguration.getTapTimeout(); + if ((VERSION.SDK_INT_FULL >= 3600001) && Flags.viewconfigurationApis()) { + mTapTimeoutMillis = ViewConfiguration.get(mTargetView.getContext()).getTapTimeoutMillis(); + } else { + mTapTimeoutMillis = ViewConfiguration.getTapTimeout(); + } } public void updateResources() { diff --git a/systemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java b/systemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java index dfb62c0b2e..06a44d29ac 100644 --- a/systemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +++ b/systemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java @@ -90,7 +90,7 @@ public class FloatingRotationButton implements RotationButton { @DimenRes int taskbarBottomMargin, @DimenRes int buttonDiameter, @DimenRes int rippleMaxWidth, @BoolRes int floatingRotationBtnPositionLeftResource) { mContext = context; - mWindowManager = WindowManagerUtils.getWindowManager(mContext); + mWindowManager = mContext.getSystemService(WindowManager.class); mKeyButtonContainer = (ViewGroup) LayoutInflater.from(mContext).inflate(layout, null); mKeyButtonView = mKeyButtonContainer.findViewById(keyButtonId); mKeyButtonView.setVisibility(View.VISIBLE);